Author Topic: Conversation on damage  (Read 1440 times)

Legacy_Tempestras

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Conversation on damage
« on: July 21, 2010, 11:15:46 am »


               Im not the best scripter so I have no idea if this is possible but here goes.

Im working on a small private project and I need a script that will activate when the NPC is damaged to give out random lines of conversation and then, when the NPC is engaged in a conversation, to act as a normal conversation would go.

Any help would be appreciated, thanks
               
               

               
            

Legacy_Tempestras

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Conversation on damage
« Reply #1 on: July 21, 2010, 11:22:57 am »


               Also, the same kind of script except to be activated when Healing the NPC instead of damaging
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversation on damage
« Reply #2 on: July 22, 2010, 05:26:42 am »


               I dont have time to write anything at the moment.  But for your first one 'one liners on damaged'. you could give the NPC a custom OnDamaged event.  just add a random switch with a few SpeakString("You did it now fiend"); functions in it.  



For the healing side you could use the OnSpellCastAt Event.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Conversation on damage
« Reply #3 on: July 22, 2010, 06:09:19 am »


               Could do something like this for the OnDamaged part as Lightfoot suggests:

//Place in the OnDamged event of the NPC to speak a random line of text.
void main()
{
int iRand = Random(8)+1;
string sSpeak;
switch (iRand)
    {
    case 1: sSpeak = "Now you've done it!";break;
    case 2: sSpeak = "You big meany!";break;
    case 3: sSpeak = "Ouch...I think I broke a nail.";break;
    case 4: sSpeak = "...";break;
    case 5: sSpeak = "...";break;
    case 6: sSpeak = "...";break;
    case 7: sSpeak = "...";break;
    case 8: sSpeak = "...";break;
    }
ActionSpeakString(sSpeak);
ExecuteScript("nw_c2_default6", OBJECT_SELF);
}


Hope that helps. Good Luck. '<img'>
               
               

               


                     Modifié par GhostOfGod, 22 juillet 2010 - 05:23 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Conversation on damage
« Reply #4 on: July 22, 2010, 06:18:55 am »


               And then something like this for the OnSpellCastAt:

//Place in the OnSpellCastAt event of the NPC to speak a random line of text.
void main()
{
int iRand = Random(8)+1;
int iSpell = GetLastSpell();
string sSpeak;
switch (iRand)
    {
    case 1: sSpeak = "That feels much better.";break;
    case 2: sSpeak = "Thank you so much for healing me.";break;
    case 3: sSpeak = "I like to feel terrible so thanks for nothing.";break;
    case 4: sSpeak = "...";break;
    case 5: sSpeak = "...";break;
    case 6: sSpeak = "...";break;
    case 7: sSpeak = "...";break;
    case 8: sSpeak = "...";break;
    }
if (iSpell == SPELL_HEAL)
    {
    ActionSpeakString(sSpeak);
    ExecuteScript("nw_c2_defaultb", OBJECT_SELF);
    }
else ExecuteScript("nw_c2_defaultb", OBJECT_SELF);
}


These both compile but haven't been tested. It's also been awhile since I've scripted but they should be ok.'<img'>

Good Luck.

P.S. Since there are many spells that can heal you may want to consider modifying this to check for other healing type spells cast other than just "Heal". If you need that as well feel free to ask.
               
               

               


                     Modifié par GhostOfGod, 22 juillet 2010 - 05:21 .
                     
                  


            

Legacy_Tempestras

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Conversation on damage
« Reply #5 on: July 22, 2010, 03:05:13 pm »


               Thankyou so much guys '^_^' Was beginning to think no one would reply heh



Ok, the OnDamage script is sorted now, thankyou again



The Healing script though im having trouble with. What if I wanted them to just say one line of text instead of randomising it AND have them use the bow emote? Also, How do I include all the healing spells in the game?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Conversation on damage
« Reply #6 on: July 22, 2010, 08:15:47 pm »


               Something more like this might work better for you then:

//Place in the OnSpellCastAt event of an NPC.
void main()
{
object oHealer = GetLastSpellCaster();
int iSpell = GetLastSpell();

if (iSpell == SPELL_HEAL ||
    iSpell == SPELL_CURE_CRITICAL_WOUNDS ||
    iSpell == SPELL_CURE_LIGHT_WOUNDS ||
    iSpell == SPELL_CURE_MINOR_WOUNDS ||
    iSpell == SPELL_CURE_MODERATE_WOUNDS ||
    iSpell == SPELL_CURE_SERIOUS_WOUNDS ||
    iSpell == SPELL_GREATER_RESTORATION)
    {
    SetFacingPoint(GetPosition(oHealer));
    ActionPlayAnimation(ANIMATION_FIREFORGET_BOW);
    ActionSpeakString("Thank you.");
    ExecuteScript("nw_c2_defaultb", OBJECT_SELF);
    }
else ExecuteScript("nw_c2_defaultb", OBJECT_SELF);
}


I've never been a good spell caster/healer  so i'm sure there are a couple spells I may have fogotten. You can add to the list of spells to check in the same fashion as above.

GetLastSpellCaster does not return a valid object if the spell is an Area Of Effect type spell. So if you add an AOE healing spell to the list, the NPC will probably still bow and speak their line but wont face the healer. Might look weird.

Hope that helps you. Good Luck.
               
               

               


                     Modifié par GhostOfGod, 22 juillet 2010 - 07:17 .
                     
                  


            

Legacy_Tempestras

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Conversation on damage
« Reply #7 on: July 22, 2010, 11:18:28 pm »


               Ghost, your a life saver! Thankyou! '^_^'
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversation on damage
« Reply #8 on: July 23, 2010, 10:21:58 pm »


               Nice work GoG.   But I do see one change I would make, Just to keep from having to list every possiable spell that comes along.





void main()
{
object oHealer = GetLastSpellCaster();
int iSpell = GetLastSpell();
int nCate = Get2DAString ("spells","Category",iSpell)
if (nCate == TALENT_CATEGORY_BENEFICIAL_HEALING_AREAEFFECT
|| nCate == TALENT_CATEGORY_BENEFICIAL_HEALING_TOUCH)
{
SetFacingPoint(GetPosition(oHealer));
ActionPlayAnimation(ANIMATION_FIREFORGET_BOW);
ActionSpeakString("Thank you.");
ExecuteScript ("nw_c2_defaultb", OBJECT_SELF);
}
else ExecuteScript ("nw_c2_defaultb", OBJECT_SELF);
[/list]}
               
               

               


                     Modifié par Lightfoot8, 23 juillet 2010 - 09:30 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Conversation on damage
« Reply #9 on: July 23, 2010, 10:27:57 pm »


               Nice. I really need to start working with the 2da stuff more.
               
               

               
            

Legacy_Tempestras

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Conversation on damage
« Reply #10 on: July 24, 2010, 01:08:37 am »


               Wow, that script would definatly save on space, thank you so much Lightfoot '<img'>