Author Topic: what did I do wrong?  (Read 518 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
what did I do wrong?
« on: December 04, 2015, 08:17:02 am »


               

okay here is a small script for a quest that I have been working on. Basically what it does it destroys the first NPC that is talking and basically replaces it with a hostile creature that the pc needs to kill.


 




void main()

{

    PWSetMinLocalIntPartyPCSpeaker("p021state_SubstituteMs", 4);

    PWSetMinLocalIntPartyPCSpeaker("p021state", 4);

    object oTarget;

 

object oTarget;

    object oSpawn;

    effect eVFX;

    object oSelf = OBJECT_SELF;

 

    // Get the PC who is in this conversation.

    object oPC = GetPCSpeaker();

 

    // Destroy an object (not fully effective until this script ends).

 

    eVFX = EffectVisualEffect(VFX_FNF_HOWL_ODD);

    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSelf);

    DestroyObject(oSelf, 3.0);

 

    // Spawn "creature006".

    oTarget = GetWaypointByTag("WP_SHE_MANTIS_001");

    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "creature006", GetLocation(oTarget));

    AssignCommand(oSpawn, DetermineCombatRound(oPC));

}

 

 



 



though I do seem to be getting an error with:     AssignCommand(oSpawn, DetermineCombatRound(oPC));


ERROR: UNDEFINED IDENTIFIER (DetermineCombatRound).


 


so what did I do wrong here?



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
what did I do wrong?
« Reply #1 on: December 04, 2015, 08:27:05 am »


               

apparently that is not my only problem...for some reason the creature does not spawn at the conversation: 


 




void main()

{

    PWSetMinLocalIntPartyPCSpeaker("p021state_William", 3);

    PWSetMinLocalIntPartyPCSpeaker("p021state", 3);

 

object oTarget;

    object oSpawn;

 

    // Get the PC who is in this conversation.

    object oPC = GetPCSpeaker();

 

    // Spawn "creature007".

    oTarget = GetWaypointByTag("WP_SUBSTITUTE_001");

    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "creature007", GetLocation(oTarget));

    AssignCommand(oSpawn, ActionStartConversation(oPC));

}

 

 



 



so any help would be appreciated '<img'> 



               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
what did I do wrong?
« Reply #2 on: December 04, 2015, 09:39:48 am »


               

DetermineCombatRound isn't a core function.  Rather, it's a scripted function in one of the many include files, so has to be linked to.  Put the include for it at the top of your script, so that it knows where to find it.


At the very top, above the void main(), put in:

#include "NW_I0_GENERIC"



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
what did I do wrong?
« Reply #3 on: December 04, 2015, 09:56:01 am »


               Like Failed.Bard said, to use DetermineCombatRound you need the following line at the very start of the script:
#include "NW_I0_GENERIC"
because that function is defined there, not in the engine. In general, it pays to add functions from the right-hand pane of the script editor. If a function is missing, refer to the Lexicon for the library file you need to include.
 
As a rule-of-thumb, scripts don't work reliably when running on objects that are about to die (or be destroyed). Simple commands do work, because they're executed immediately, before the object disappears, but assigned and delayed commands generally don't, because they're flushed when the object ceases to exist (a bit like an army running away when the general is killed).
 
There are many ways to achieve what you want here. One is to change the appearance of the speaker into a monster, so that it is never destroyed. Another is to have the speaker assign a command to the Module:
AssignCommand(GetModule(), .... // Put function here that creates monster and gives it commands
The module is an exception to the general rule here.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
what did I do wrong?
« Reply #4 on: December 04, 2015, 10:02:46 am »


               

The way I do it is to assign the creature to the "commoner" faction then, at the point I want it to turn hostile in the conversation, I use an action taken script using the ChangeToStandardFaction() function to change the creature's faction to hostile. You don't need to destroy the first NPC and spawn in a replacement using this method. As Proleric states, if the NPC needs to change appearance, you can then script in the appearance change, adding the necessary command to the block of code given below.


 



   Spoiler
   


 


Just for reference, this snippet of code is part of a larger action taken script used in the conversation of a locked door. In the conversation, the PC is talking to a scared NPC through the locked door, asking them to open the door. When the PC eventually smashes the door via conversation options, the NPC inside the room attacks.



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
what did I do wrong?
« Reply #5 on: December 04, 2015, 04:22:45 pm »


               

well I cannot really test all that out if I cannot get the 2nd npc to spawn on conversation in the first place as I posted in the second post in here:


 




void main()

{

    PWSetMinLocalIntPartyPCSpeaker("p021state_William", 3);

    PWSetMinLocalIntPartyPCSpeaker("p021state", 3);

 

object oTarget;

    object oSpawn;

 

    // Get the PC who is in this conversation.

    object oPC = GetPCSpeaker();

 

    // Spawn "creature007".

    oTarget = GetWaypointByTag("WP_SUBSTITUTE_001");

    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "creature007", GetLocation(oTarget));

    AssignCommand(oSpawn, ActionStartConversation(oPC));

}

 



 



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
what did I do wrong?
« Reply #6 on: December 04, 2015, 04:39:30 pm »


               

okay everything works just not the instant attacking of the she-mantis when fully spawned. It just stands there and well then ignores the attacking player completely 0.0



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
what did I do wrong?
« Reply #7 on: December 04, 2015, 04:52:55 pm »


               

oh, nevermind, I think I found the issue! Thanks for the help guys! '<img'>



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
what did I do wrong?
« Reply #8 on: December 05, 2015, 05:58:18 pm »


               

okay as a follow up question for a similar situation. I just would like to know how to make the npc change its appearance from normal human to a different creature.


 


basically what I want is the following for a quest: 


 


pc talks to someone and hears him talk about them getting what they deserve. PC decides to talk to one of the NPC's in questions and in dialogue they will turn into a monster!


 


in that conversation I want to have at least 6 NPC's change their appearance from normal human to a monster appearance, and all that after only 1 conversation. Any thoughts on how to tackle this?


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
what did I do wrong?
« Reply #9 on: December 05, 2015, 08:33:00 pm »


               http://www.nwnlexico...eAppearanceType


Use e.g. GetObjectByTag to identify each creature, using unique tags, or an nth tag loop, as convenient.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
what did I do wrong?
« Reply #10 on: December 05, 2015, 09:23:29 pm »


               

What Proleric said. Furthermore, the APPEARANCE_TYPE_ constants correspond directly to line numbers in appearance.2da. Therefore, you can just use the line number instead of the actual constant (also works good if you have custom appearances). Thus, the code would look like this...


 



   Spoiler
   


 


In the snippet above, "oTarget" is the creature you wish to change the appearance of and "###" is the line number from appearance.2da of the appearance you wish to change to.


 


A more advanced method would be to use EffectPolymorph() - especially if yo are talking shapechangers here (e.g. humans changing to werewolves or vampires going all "vampy" (I believe that's what Willow called it - yes, I love that show). With EffectPolymorph() you can change more than just the appearance of the creature, boosting its stats and adding items to creature slots - look at polymorph.2da and you'll see what I mean. Lastly, by editing polymorph.2da you can add new polymorph types or tailer the existing ones to suit your needs.



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
what did I do wrong?
« Reply #11 on: December 05, 2015, 10:13:49 pm »


               


What Proleric said. Furthermore, the APPEARANCE_TYPE_ constants correspond directly to line numbers in appearance.2da. Therefore, you can just use the line number instead of the actual constant (also works good if you have custom appearances). Thus, the code would look like this...


 



   Spoiler
   


 


In the snippet above, "oTarget" is the creature you wish to change the appearance of and "###" is the line number from appearance.2da of the appearance you wish to change to.


 


A more advanced method would be to use EffectPolymorph() - especially if yo are talking shapechangers here (e.g. humans changing to werewolves or vampires going all "vampy" (I believe that's what Willow called it - yes, I love that show). With EffectPolymorph() you can change more than just the appearance of the creature, boosting its stats and adding items to creature slots - look at polymorph.2da and you'll see what I mean. Lastly, by editing polymorph.2da you can add new polymorph types or tailer the existing ones to suit your needs.




 


awesome! Yeah I love the show as well (well doh hence why I am making a module out of it '<img'>) basically am somewhat recreating the episode of Beer Bad and honestly everything is going great! Just need to learn a bit more about the scripting and I so appreciate the help I am getting from the forums here '<img'> 


 


but yeah I kinda wanna go for a polymorph since they should be stronger than jack from next door (cavepeople having more muscles and suchies)


 


so any help in that regard would be totally awesome! '<img'>


               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
what did I do wrong?
« Reply #12 on: December 06, 2015, 12:09:08 am »


               

Ok, you've peeked my interest enough - and that is the MOST AWESOME EPISODE ever (well, except for "Once More, With Feeling") - to help you out. What you'll need is a custom polymorph - no problem I can do that - and a custom model. What I'm going to do is scale the DLA ogre down a tad (I'll use the a_ba linked version from Q so the model will have all the animations available to PC's). The model is brutish enough that it'll make fine "caveman" - I'm thinking about 10% larger than a human. What do you think? Also what kind of ideas for stat modifications (remember you're limited to what's available via polymorph.2da and a creature skin item?



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
what did I do wrong?
« Reply #13 on: December 06, 2015, 01:26:06 am »


               


Ok, you've peeked my interest enough - and that is the MOST AWESOME EPISODE ever (well, except for "Once More, With Feeling") - to help you out. What you'll need is a custom polymorph - no problem I can do that - and a custom model. What I'm going to do is scale the DLA ogre down a tad (I'll use the a_ba linked version from Q so the model will have all the animations available to PC's). The model is brutish enough that it'll make fine "caveman" - I'm thinking about 10% larger than a human. What do you think? Also what kind of ideas for stat modifications (remember you're limited to what's available via polymorph.2da and a creature skin item?




 


omg that is awesome thanks so much pstemarie!


 


Okay well about the stats I am a bit unsusre, I actually just took a hobgoblin as a base and started from there....basically having the pc 7 barbarian level I would reckon like strength up to 23-24 and a small boost in dex and constitution? Unless that was not what you meant? 


anyway also thought it would be cool to have them hurl up some rocks to toss at the pc.  but other than that uhm (flabberghasted!)


 


but yeah Beer Bad is like one of my more favorite episodes of buffy, my most favorite is of course once more with feeling! Got the soundtrack CD that I listen to every now and then XD



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
what did I do wrong?
« Reply #14 on: December 06, 2015, 10:31:18 am »


               

They made a soundtrack for that episode - now I know what to get my wife for X-Mas.