From: Laszlo T. <ave...@us...> - 2011-07-10 13:18:30
|
gemrb: Infinity Engine emulator The branch master has been updated via 114de8a6078e89e03b7e0664242217a975cf71c4 (commit) Summary of changes: gemrb/core/GameScript/GSUtils.cpp | 37 +++------------- gemrb/core/Scriptable/Actor.cpp | 83 +++++++++++++++++++++++++------------ gemrb/core/Scriptable/Actor.h | 4 ++ 3 files changed, 67 insertions(+), 57 deletions(-) from 9e1cada385c54e0c7e90a0f256752b630193e759 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=114de8a6078e89e03b7e0664242217a975cf71c4 commit 114de8a6078e89e03b7e0664242217a975cf71c4 Author: Avenger <ave...@so...> Date: Sun Jul 10 15:16:55 2011 +0200 fixed ToB banters to use the correct banter dialog moved the bg1 style oneliners out of Interact action diff --git a/gemrb/core/GameScript/GSUtils.cpp b/gemrb/core/GameScript/GSUtils.cpp index 53be137..e390d4a 100644 --- a/gemrb/core/GameScript/GSUtils.cpp +++ b/gemrb/core/GameScript/GSUtils.cpp @@ -781,25 +781,6 @@ void GetPositionFromScriptable(Scriptable* scr, Point &position, bool dest) } } -int CheckInteract(const char *talker, const char *target) -{ - AutoTable interact("interact"); - if(!interact) - return 0; - const char *value = interact->QueryField(talker, target); - if(!value) - return 0; - switch(value[0]) { - case 's': - return I_SPECIAL; - case 'c': - return I_COMPLIMENT; - case 'i': - return I_INSULT; - } - return 0; -} - static ieResRef PlayerDialogRes = "PLAYERx\0"; void BeginDialog(Scriptable* Sender, Action* parameters, int Flags) @@ -955,20 +936,16 @@ void BeginDialog(Scriptable* Sender, Action* parameters, int Flags) } const char* scriptingname = scr->GetScriptName(); - /* use interact.2da for short, inlined dialogue */ - int type = CheckInteract(scriptingname, target->GetScriptName()); - if(type) { - //TODO increase interact counter in scr - speaker->Interact(type); - target->Response(type); - Sender->ReleaseCurrentAction(); - return; - } /* banter dialogue */ pdtable.load("interdia"); - //Dialog is a borrowed reference, we cannot free pdtable while it is being used + //Dialog is a borrowed reference, and pdtable will be freed automagically if (pdtable) { - Dialog = pdtable->QueryField( scriptingname, "FILE" ); + //5 is the magic number for the ToB expansion + if (game->Expansion==5) { + Dialog = pdtable->QueryField( scriptingname, "25FILE" ); + } else { + Dialog = pdtable->QueryField( scriptingname, "FILE" ); + } } break; } diff --git a/gemrb/core/Scriptable/Actor.cpp b/gemrb/core/Scriptable/Actor.cpp index 4148eb4..a9839b5 100644 --- a/gemrb/core/Scriptable/Actor.cpp +++ b/gemrb/core/Scriptable/Actor.cpp @@ -127,7 +127,7 @@ struct ItemUseType { static ItemUseType *itemuse = NULL; static int usecount = -1; -static bool pstflags = false; +static ieDword pstflags = false; static bool nocreate = false; //used in many places, but different in engines static ieDword state_invisible = STATE_INVISIBLE; @@ -1385,8 +1385,8 @@ static void InitActorTables() core->GetDictionary()->Lookup("Selection Sounds Frequency", sel_snd_freq); core->GetDictionary()->Lookup("Command Sounds Frequency", cmd_snd_freq); core->GetDictionary()->Lookup("Bored Timeout", bored_time); - pstflags = core->HasFeature(GF_PST_STATE_FLAGS); - nocreate = core->HasFeature(GF_NO_NEW_VARIABLES); + pstflags = !!core->HasFeature(GF_PST_STATE_FLAGS); + nocreate = !!core->HasFeature(GF_NO_NEW_VARIABLES); if (pstflags) { state_invisible=STATE_PST_INVIS; } else { @@ -2511,6 +2511,8 @@ void Actor::Interact(int type) case I_INSULT: start=VB_INSULT; count=3; break; case I_COMPLIMENT: start=VB_COMPLIMENT; count=3; break; case I_SPECIAL: start=VB_SPECIAL; count=3; break; + case I_INSULT_RESP: start=VB_RESP_INS; count = 3; break; + case I_COMPL_RESP: start=VB_RESP_COMP; count = 3; break; default: return; } @@ -2541,29 +2543,8 @@ void Actor::VerbalConstant(int start, int count) const count--; } if(count>=0) { - DisplayStringCore((Scriptable *const) this, start+count, DS_CONSOLE|DS_CONST ); - } -} - -void Actor::Response(int type) const -{ - int start; - int count; - ieStrRef vc; - - switch(type) { - case I_INSULT: start=VB_RESP_INS; count=3; break; - case I_COMPLIMENT: start=VB_RESP_COMP; count=3; break; - default: - return; - } - - count=rand()%count; - while(count && ((vc = GetVerbalConstant(start+count))!=(ieStrRef) -1)) { - count--; - } - if(count>=0) { - DisplayStringCore((Scriptable *const) this, start+count, DS_CONSOLE|DS_CONST ); + //DisplayStringCore((Scriptable *const) this, start+count, DS_CONSOLE|DS_CONST ); + DisplayStringCore((Scriptable *const) this, vc, DS_CONSOLE ); } } @@ -2624,6 +2605,47 @@ void Actor::GetAreaComment(int areaflag) const } } +static int CheckInteract(const char *talker, const char *target) +{ + AutoTable interact("interact"); + if(!interact) + return 0; + const char *value = interact->QueryField(talker, target); + if(!value) + return 0; + switch(value[0]) { + case 's': + return I_SPECIAL; + case 'c': + return I_COMPLIMENT; + case 'i': + return I_INSULT; + case 'I': + return I_INSULT_RESP; + case 'C': + return I_COMPL_RESP; + } + return 0; +} + +bool Actor::HandleInteract(Actor *target) +{ + int type = CheckInteract(scriptName, target->GetScriptName()); + if (!type) return false; + + Interact(type); + switch(type) + { + case I_COMPLIMENT: + target->Interact(I_COMPL_RESP); + break; + case I_INSULT: + target->Interact(I_INSULT_RESP); + break; + } + return true; +} + bool Actor::GetPartyComment() { Game *game = core->GetGame(); @@ -2643,6 +2665,13 @@ bool Actor::GetPartyComment() if (target==this) continue; if (target->BaseStats[IE_MC_FLAGS]&MC_EXPORTABLE) continue; //not NPC if (target->GetCurrentArea()!=GetCurrentArea()) continue; + + //simplified interact + if (HandleInteract(target)) { + return true; + } + + //V2 interact char Tmp[40]; strncpy(Tmp,"Interact([-1])", sizeof(Tmp) ); Action *action = GenerateActionDirect(Tmp, target); @@ -4438,7 +4467,7 @@ bool Actor::GetCombatDetails(int &tohit, bool leftorright, WeaponInfo& wi, ITMEx { tohit = GetStat(IE_TOHIT); speed = -GetStat(IE_PHYSICALSPEED); - bool dualwielding = IsDualWielding(); + ieDword dualwielding = IsDualWielding(); header = GetWeapon(wi, leftorright && dualwielding); if (!header) { return false; diff --git a/gemrb/core/Scriptable/Actor.h b/gemrb/core/Scriptable/Actor.h index f58eab2..0f0baec 100644 --- a/gemrb/core/Scriptable/Actor.h +++ b/gemrb/core/Scriptable/Actor.h @@ -138,6 +138,8 @@ struct PolymorphCache; #define I_INSULT 1 #define I_COMPLIMENT 2 #define I_SPECIAL 3 +#define I_INSULT_RESP 4 +#define I_COMPL_RESP 5 // 3 for blur, 8 for mirror images #define EXTRA_ACTORCOVERS 11 @@ -591,6 +593,8 @@ public: void GetSoundFrom2DA(ieResRef Sound, unsigned int index) const; /* generate area specific oneliner */ void GetAreaComment(int areaflag) const; + /* handle oneliner interaction */ + bool HandleInteract(Actor *target); /* generate party banter, return true if successful */ bool GetPartyComment(); /* sets the quick slots */ ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |