Aller au contenu

Photo

Special Ability


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

#1
ZX_Diablo

ZX_Diablo
  • Members
  • 57 messages
Can anyone tell me how to trigger special ability using a magic word. I want my PC to have a special ability but I'm stuck, as player character's file format doesnt include them at
all.

#2
WhiZard

WhiZard
  • Members
  • 1 204 messages
Module properties: OnPlayerChat script.

#3
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
You will want to use the modules OnPlayerChat event and use a script that looks something kinda like so:


void main()
{
    string sMessage = GetPCChatMessage();
    object oSpeaker = GetPCChatSpeaker();

    if (sMessage == "abracadabra" || sMessage == "Abracadabra")
    {
        if (some other condition)
        {
            //do stuff for powers here
        }
    }

    if (sMessage == "alakazam" || sMessage == "Alakazam")
    {
        if (some other condition)
        {
            //do stuff for powers here
        }
    }
}

This is pretty generic but it might get you going in the right direction. The OnPlayerChat intercepts the messages that players type in the chat. You will notice I put in a spot for "some other condition" in case you don't want just anybody to be able to blab out a magic word and get powers. They have to say the word and they have to pass some other check. Like being a wizard, or possess an item, etc...

Hope this helps.

#4
ZX_Diablo

ZX_Diablo
  • Members
  • 57 messages
Thanks guys. I will try it now.

Modifié par ZX_Diablo, 18 août 2011 - 12:47 .


#5
ZX_Diablo

ZX_Diablo
  • Members
  • 57 messages
It doesn't compile. An error occurs in the compile tab "ERROR: PARSING VARIABLE LIST", and highlights the "string sMessage = GetPCChatMessage();".

#6
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Are you running 1.69? If so post your script. If not that is probably your problem.

Modifié par GhostOfGod, 18 août 2011 - 01:12 .


#7
ZX_Diablo

ZX_Diablo
  • Members
  • 57 messages
I am not running 1.69.

#8
ZX_Diablo

ZX_Diablo
  • Members
  • 57 messages
I have created a "on_playerchat" script, because in my module, there is no "on_playerchat" ...

Modifié par ZX_Diablo, 18 août 2011 - 01:54 .


#9
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
If you don't have the OnPlayeChat event then you are going to have to go old school and use listeners. That is something I have no experience with so someone else will have to help you out with this one. Sorry.

You might want to take a look at this and see if it helps: nwvault.ign.com/View.php

Modifié par GhostOfGod, 18 août 2011 - 02:13 .