Hey Tony,
I'm trying to implement a reputation score that's individualized per NPC, but I'm not sure exactly how to have Dialogue Manager check for it. I could put the variable on a script on the NPC, but how do I send the game object of the conversant over script?
Unless there's a way to have individual variables on each conversation? that might be easier.
Individual Reputation
Re: Individual Reputation
Hi,
The Dialogue System has a simple relationship system. (See: Relationship Lua Functions) Relationship values are included in saved games.
Let's say you have an NPC named Bob. So your dialogue database has actors named Player and Bob. Use the relationship functions to set Bob's relationship to the player. Examples:
If you're writing a conversation that can be reused by multiple NPCs, you can use Variable["ConversantIndex"] to refer to the conversant (NPC). Example:
If you don't want to use the Dialogue System's built-in relationship system, you can write your own in C# and register your C# methods with Lua so you can use them in your conversations' Conditions and Script fields.
The Dialogue System has a simple relationship system. (See: Relationship Lua Functions) Relationship values are included in saved games.
Let's say you have an NPC named Bob. So your dialogue database has actors named Player and Bob. Use the relationship functions to set Bob's relationship to the player. Examples:
- Dialogue Text [Bob]: "Thanks for the help! You're a good person."
- Script: IncRelationship(Actor["Bob"], Actor["Player"], "Reputation", 15); -- Increase rep with Bob by +15
- Dialogue Text [Ann]: "Hi! Bob mentioned what a nice person you are."
- Conditions: GetRelationship(Actor["Bob"], Actor["Player"], "Reputation") >= 10
If you're writing a conversation that can be reused by multiple NPCs, you can use Variable["ConversantIndex"] to refer to the conversant (NPC). Example:
- Dialogue Text: "Thanks for the help! You're a good person."
- Script: IncRelationship(Actor[Variable["ConversantIndex"]], Actor["Player"], "Reputation", 15);
If you don't want to use the Dialogue System's built-in relationship system, you can write your own in C# and register your C# methods with Lua so you can use them in your conversations' Conditions and Script fields.
Re: Individual Reputation
This looks perfect! Can I get/set these values in script outside of dialogue manager also?
Re: Individual Reputation
Yes. You can use Lua.Run() to run the Lua function:
Code: Select all
Lua.Run("IncRelationship(Actor['Bob'], Actor['Player'], 'Reputation', 15)");
Code: Select all
Language.Lua.LuaTable bob = Lua.Run("return Actor['Bob']").luaValue as Language.Lua.LuaTable;
Language.Lua.LuaTable player = Lua.Run("return Actor['Player']").luaValue as Language.Lua.LuaTable;
DialogueLua.IncRelationship(bob, player, "Reputation", 15);
Re: Individual Reputation
how do I use lua.run to get the actual value? I was only getting back a lua-result
Re: Individual Reputation
Sorry, I forgot to mention that. Use ".asFloat" at the end (or .asInt, .asString, .asBool, or .asTable for other types).
Code: Select all
float rep = Lua.Run("return GetRelationship(Actor['Bob'], Actor['Player'], 'Reputation')").asFloat;