Jump to content


Photo

Pullin' the old switcheroo trick (PLEASE help!)


  • Please log in to reply
9 replies to this topic

#1 Keldon

Keldon
  • Member
  • 62 posts

Posted 20 February 2007 - 03:25 PM

I have a question that I am hoping one of you more experienced modders can answer.
At some point, I want my NPC to speak to a merchant and, in dialogue, have him upgrade her dagger to another that will actually be useful in ToB.
I know that when the characters come out of the underdark and their drow items get changed to adamintine dust the coding goes like this
IF
Global("DROWITEMCHECKDONE","GLOBAL",0)
HasItem("DWCHAN01",Player1)
THEN
RESPONSE #100
TakeItemReplace("DWDUST","DWCHAN01",Player1)
................ (more actions)
END

How do I change this into what I need for my NPC and in which file do I put it?

Thank you
Keldon

#2 Thauron

Thauron
  • Member
  • 216 posts

Posted 21 February 2007 - 01:22 AM

If I understand correctly - you won't need a script, but you'll have to create a dialogue between your NPC and the smith, in which you switch the old item for a new, upgraded one. Let your NPC interject into the normal smith dialogue if she has the right item and talk about an upgrade, than add the code.

Several NPCs have examples of that - If I am not mistaken Kelsey, Sheena and several others have such a dialogue. - maybe it would be best to check that out - mods of others are always the best tutorials. ;)

Edited by Thauron, 21 February 2007 - 01:24 AM.


#3 Lord Ernie

Lord Ernie
  • Modder
  • 755 posts

Posted 21 February 2007 - 02:24 AM

Actually, you can look these things up in the IESDP (or, in this case, look at the code... it replaces the item in the IF with dust). If you look under BG2 Script Actions, you can see the following:

TakeItemReplace(S:Give*,S:Take*,O:Object*)

So adapting the script for your item (MyItem1 and 2) would look like:

IF
Global("MYITEMSWITCH","GLOBAL",0)
HasItem("MYITEM1",Player1)
THEN
 RESPONSE #100
  TakeItemReplace("MYITEM2","MYITEM1",Player1)
END

In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams

I like persons better than principles, and I like persons with no principles better than anything else in the world - Oscar Wilde

Give a man a fire, and he's warm for a day. But set a man on fire, and he's warm for the rest of his life. - Terry Pratchett


#4 Rabain

Rabain

    God

  • Member
  • 653 posts

Posted 21 February 2007 - 10:12 AM

Yes if you can get the dialog between the merchant and your npc to appear correctly in game then all you need is TakeItemReplace("givenewitem","takeolditem","npcCrename") at the end of the dialog.

If you try to get the dialog to work and then post the dialog code when you have that we can show where to put the appropriate Action.
A knight without armour in a savage land...

#5 Keldon

Keldon
  • Member
  • 62 posts

Posted 21 February 2007 - 11:34 AM

Hi everyone!

Thank you very much for the help you gave me on this one! it was very much appreciated.

I now have a second question.....I have coded it so that, on two different occasions, my NPC can go hostile and attack the PC. Now, I have tried it with each entry going to their perspective attk1 and attk2, and both of them going to just attk2.
The reason for this is that in the first case, the NPC goes hostile but then just stands there, won't even attack back if the PC attacks her.
In the second case, everything goes exactly as I want it to, she goes hostile and attacks the PC.
Since there is no difference in the coding, how come she won't attack the first time but she will the second?
Does anyone know the answer to this?

Thank you
Keldon

#6 Thauron

Thauron
  • Member
  • 216 posts

Posted 21 February 2007 - 12:35 PM

Without your code, we can't have any clue why things aren't working as they should. - or at least I can't ;)

Maybe if you can post the relevant parts from your dialogue and your NPC-override script we might be able to figure it out.

#7 Sticz

Sticz

    Monkey - In the time of Chimpanzees

  • Member
  • 385 posts

Posted 27 February 2007 - 11:15 AM

Be sure that you are setting your commands correctly. It sounds as if you are only making the merchant Enemy() and the other is Enemy()Attack(PLAYER1), etc. Most of your peasant or innocent fodder does not have an Attack() portion in their script, so they will either just stand there or run away.


Sticz
"For a crazy person, you don't drool much." Complement from Dilbert's Wally.

#8 Keldon

Keldon
  • Member
  • 62 posts

Posted 27 February 2007 - 11:45 AM

Thanks Sticz
I will code that in when I get home and see how it works for me!

Keldon

#9 Deathsangel

Deathsangel

    Living on Wings of Dreams

  • Modder
  • 3089 posts

Posted 28 February 2007 - 12:47 AM

You can also give a common attack script, for most of the times you don't need all of them and than simply Attack(Player1) is enough.

Still modding the Mod for the Wicked... It is a big project you know... And I got sidetracked (several times) a bit... sorry.
However, as we all know, Evil never really sleeps.


Sentences marking (my) life:

Winds of change... Endure them, and in Enduring grow Stronger
It takes a fool to look for logic in a man's heart
Never question the sanity of the insane
The Harmony of Life is Chaos
Living on Wings of Dreams



(1st march 2009) SHS women over me:
Kat: if there were more guys that looked like you out here, people's offspring wouldnt be so damn ugly
Noctalys: you are adorable :P

~~ I love it, and I am humbled! Yay! ~~


#10 Keldon

Keldon
  • Member
  • 62 posts

Posted 28 February 2007 - 08:54 AM

Hi everybody,

Thank you for all your support on this issue. I have finally been successful in getting my NPC to go hostile on command.
I used DeathsAngel's idea of adding it to the dialogue file but added in a few other parts of coding that other people had suggested.
It took some teamwork, but working together, we were successful and I want to extend a heartfelt thanks to all who helped.

Peace
Keldon