Aller au contenu

On Death Script question.


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
Guest_Iveforgotmypassword_*

Guest_Iveforgotmypassword_*
  • Guests
I've put this script in the on death property of a creature but it only seems to work if the PC kills it. What bit should I change and can I just put the start conversation part in instead of all the object oPC and get is PC part ? Or what do I need to add to make it happen however it dies ?

void main()
{
object oPC = GetLastKiller();
if (!GetIsPC(oPC)) return;
object oTarget;
oTarget = GetObjectByTag("kim");
AssignCommand(oTarget, ActionStartConversation(oPC, "dead_troll",FALSE,FALSE,TRUE,FALSE));
}

Thank you.

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
If you're dealing with a party with companions and animals, you can use GetFactionLeader and all the related functions to get the main PC connected to the killer. If the PC can kill the thing indirectly, then the GetLastKiller thing won't work. You could try to find the nearest real PC to the dying NPC for the conversation (GetNearestObjectByType).

GetFirstPC will work, at the expense of borking it for multiplayer. If you have some sort of conversation with the NPC before the fight, you could always set the talking PC to a local object on the NPC, and then just use that local object to start the conversation (assuming the PC hasn't been knocked out during the fight).

#3
Shallina

Shallina
  • Members
  • 1 012 messages
if (!GetIsPC(oPC)) return;

This line means that the conversation will trigger only if the killer is the PC controlled character.

#4
Claudius33

Claudius33
  • Members
  • 258 messages
Firing a convo in a OnDeath event is rather tricky.

As mentionned by Shalina you must remove the test GetIsPC().
As previously said by Lugaid, GetFirstPC() is 100% sure to determine the PC.

You may use Lugaid's other suggestions if it's appropriate. You may use also :
object oPC = GetMaster(GetLastKiller());
It will work if the killer can only be a member of the party, but isn't robust enough if the troll can be killed by an allied not in the party.

However whatever the solution you choose you may face other troubles.
- If the PC and/or Kim are knocked out the convo won't fire.
- If the PC and/or Kim orders stacks are not emptied the convo may get broken.

In addition either Kim or the PC will have to run toward each other, so optionally jump Kim close to the PC.
I'd suggest the following code :

void main()
{
    object oPC = GetFirstPC();                       // or whatever solution you choose
    object oKim = GetObjectByTag("kim");  // it makes your code more readable 6 months later!

    AssignCommand(oPC, ClearAllActions(TRUE))    // clear PC actions and end combat state
    AssignCommand(oKim, ClearAllActions());           // clear Kim actions
    ForceRest(oPC);                                                          // rest PC in case s/he is unconscious
    ForceRest(oKim);                                                        // rest Kim

    AssignCommand(oKim, ActionJumpToObject(oPC));    // optional

    // tiny delay to ensure everything is done
    DelayCommand(0.1f, AssignCommand(oPC, ActionStartConversation(oKim, "dead_troll",FALSE,FALSE,TRUE,FALSE)));
}

Modifié par Claudius33, 02 octobre 2012 - 07:02 .


#5
Guest_Iveforgotmypassword_*

Guest_Iveforgotmypassword_*
  • Guests
Thank you both it's sorted now. I wiped out the if(GetIsPC(oPC)) bit and the GetLastKiller and put in GetFirstPC instead ( no chance of multiplayer in my mod ) gave the conversation to an NPC that was upstairs away from the fight and changed the speaker/listener parts on the conversation.

Now all I have to do is repair my module as I've moved waypoints and made things easier to kill for testing with a whole party but that's the easy bit.

#6
Guest_Iveforgotmypassword_*

Guest_Iveforgotmypassword_*
  • Guests
Claudius33.. You must have posted just as I was writing but I like your solution a lot as mine was a bit unsubtle and did involve kim being a long way off as she's a caster. Thank you I'll be testing this very soon before my module repairs.

#7
Guest_Iveforgotmypassword_*

Guest_Iveforgotmypassword_*
  • Guests
I had to tweak it a bit but it's absolutely what I wanted the one problem I had was that if madam Kim was in the middle of a spell when the troll hit the deck she couldn't speak more than one line so I used the man upstairs again. This is the final version..

void main()
{
object oPC = GetFirstPC();
object oKim = GetObjectByTag("kim");
object oTarget;
oTarget = GetObjectByTag("man_upstairs");
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oKim, ClearAllActions(TRUE));
ForceRest(oPC);
ForceRest(oKim);
AssignCommand(oKim, ActionJumpToObject(oPC));
DelayCommand(0.1f, AssignCommand(oPC, ActionStartConversation(oTarget, "dead_troll",FALSE,FALSE,TRUE,FALSE)));
}

Thank you very much I now get to have my band of heroes enjoying their victory in style.

#8
Claudius33

Claudius33
  • Members
  • 258 messages
Very good. Glad it helped.

#9
Guest_Iveforgotmypassword_*

Guest_Iveforgotmypassword_*
  • Guests
It did indeed and you're now in my module it's got your name and date on the script. The last thing I had to do was to make the troll decay as the conversation was looking a bit silly with everybody standing waist deep in a dead troll ( he was a big one ).

#10
Claudius33

Claudius33
  • Members
  • 258 messages
Thanks. Very serene of yours (if I may) :)

#11
Guest_Iveforgotmypassword_*

Guest_Iveforgotmypassword_*
  • Guests
You may indeed.