Jump to content
Masuka00

Npc Talk depending gender

Recommended Posts

Greetings, I would like to know how to put an NPC that gives an initial greeting or starts a conversation depending on the gender of the character or the type.

 

Spoiler

function r_talk02 ()

    
    Talk( 1, "Old granny: Hi! Lance." )

 

    Talk( 1, "Old granny: Hi! Ami." )


    Text( 1, "Leave", CloseTalk)

 

If someone could give me a hand, I would really appreciate it.


☠️🏴‍☠️💀ǤØĐ βŁ€ŞŞ ƤƗŘΔĆ¥💀🏴‍☠️☠️

Share this post


Link to post
Share on other sites
On 7/21/2022 at 12:47 PM, Masuka00 said:

Greetings, I would like to know how to put an NPC that gives an initial greeting or starts a conversation depending on the gender of the character or the type.

 

  Hide contents

function r_talk02 ()

    
    Talk( 1, "Old granny: Hi! Lance." )

 

    Talk( 1, "Old granny: Hi! Ami." )


    Text( 1, "Leave", CloseTalk)

 

If someone could give me a hand, I would really appreciate it.

It’s not possible since you do not have the player’s role in the NPC function. 
 

If you’re using Corsairs file on the other hand, they created a system called “extNpc” which allows you to use the player’s role. 

Share this post


Link to post
Share on other sites

Hello @Masuka00,

 

You can use the following example, but it covers only two cases:

function px_FuncName()
 
    InitTrigger()
    TriggerCondition(1, CheckFunction) -- CheckFunction() is any function that returns LUA_TRUE or LUA_FALSE, accepts role, npc and other given parameters
    TriggerAction(1, JumpPage, 1)
    TriggerFailure(1, JumpPage, 2 )
    Start(GetMultiTrigger(), 1)
   
    Talk( 1, "CheckFunction() returned LUA_TRUE" )
    Talk( 2, "CheckFunction() returned LUA_FALSE" )
   
end

 

Also look at transmittal() function from the file NpcScript02.lua. This code looks interesting:

	InitTrigger()
	TriggerCondition( 1, IsMapNpc, "garner", 96 )
	TriggerAction( 1, JumpPage, 1 )
	TriggerCondition( 2, IsMapNpc, "garner", 94 )
	TriggerAction( 2, JumpPage, 2 )
	TriggerCondition( 3, IsMapNpc, "garner", 95 )
	TriggerAction( 3, JumpPage, 4 )
	TriggerCondition( 4, IsMapNpc, "garner", 97 )
	TriggerAction( 4, JumpPage, 5 )
	TriggerCondition( 5, IsMapNpc, "garner", 55 )
	TriggerAction( 5, JumpPage, 6 )
	TriggerCondition( 6, IsMapNpc, "garner", 56 )
	TriggerAction( 6, JumpPage, 3 )
	TriggerCondition( 7, IsMapNpc, "magicsea", 50 )
	TriggerAction( 7, JumpPage, 7 )
	TriggerCondition( 8, IsMapNpc, "magicsea", 46 )
	TriggerAction( 8, JumpPage, 8 )
	TriggerCondition( 9, IsMapNpc, "darkblue", 56 )
	TriggerAction( 9, JumpPage, 9 )
	TriggerCondition( 10, IsMapNpc, "darkblue", 42 )
	TriggerAction( 10, JumpPage, 10 )
	TriggerCondition( 11, IsMapNpc, "darkblue", 46 )
	TriggerAction( 11, JumpPage, 11 )
	TriggerCondition( 12, IsMapNpc, "darkblue", 51 )
	TriggerAction( 12, JumpPage, 12 )
	Start( GetMultiTrigger(), 12 )

 

You can write your custom function that will check characters type:

function CheckRace(role, race_id)
    local cha_race = GetChaTypeID(role)
 
    if cha_race == race_id then
        return LUA_TRUE
    end
 
    return LUA_FALSE
end

 

Don't forget add it in the file MissionSdk.lua:

elseif conditions[i].func == CheckRace then
                PRINT( "ConditionsTest: CheckRace")
                local ret = CheckRace(character, conditions[i].p1)
                if ret ~= LUA_TRUE then
                    PRINT( "ConditionsTest: CheckRace = false" )
                    return LUA_FALSE
                en

 

Then try to write something like this:

function npc_NotTested()

	InitTrigger()
	TriggerCondition(1, CheckRace, 1)
	TriggerAction(1, JumpPage, 1)
	TriggerCondition(2, CheckRace, 2)
	TriggerAction(2, JumpPage, 2)
	TriggerCondition(3, CheckRace, 3)
	TriggerAction(3, JumpPage, 3)
	TriggerCondition(4, CheckRace, 4)
	TriggerAction(4, JumpPage, 4)
	Start(GetMultiTrigger(), 4)
	
	Talk(1, "Lance")
	Talk(2, "Carsise")
	Talk(3, "Phyllis")
	Talk(4, "Ami")
	
end

 

  • Thanks 1

Share this post


Link to post
Share on other sites

@V3ct0r Yes, he can add a condition for each character, but if he wanted to create an NPC with 10 pages, then he can’t do that due to needing 40 pages in total and only having a limit of 32 I think? 
 

as for the transmittal function, that only check for npc ID. 

Share this post


Link to post
Share on other sites
6 hours ago, Angelix said:

It’s not possible since you do not have the player’s role in the NPC function. 

 

54 minutes ago, Angelix said:

@V3ct0r Yes, he can add a condition for each character, but if he wanted to create an NPC with 10 pages, then he can’t do that due to needing 40 pages in total and only having a limit of 32 I think? 
 

as for the transmittal function, that only check for npc ID. 

Pages could be extended, it is just a matter of changing a var 


Kind regards, AG.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...