Ted's RPG Rant

A place to rant about RPG games, particularly the Temple of Elemental Evil. Co8 members get a free cookie for stopping by. Thats ONE cookie each, no seconds.

Thursday, October 20, 2005

Transferring items

Ok this is a bit fiddly, by which I mean I can't always get it to work. So rather than explaining things I will simply detail methods that have worked for me and a few that haven't but are used in game or by Liv.

When I first started on Desperate Housewives I wanted the NPCs you were fedexing things from to actually have the gear in their possession, in their inventories, and then transfer it over to yours when the moment came: hence evil characters who couldn't be bothered running around could always say lop Myella's head off and just grab the cauldron that way. Wouldn't always have been appropriate, eg Sunom or Clarisse, but for Mandy or Paida or Glora it would have been fine.

BUT when I tried to do it, I just couldn't get it to work - the transfering, that is. Can't remember if I could even get it into the characters inventory, probably I couldn't because I wasn't mobbing it in, I was just writing it into the InvenSource.mes. Well, I was a n00b back then and didn't know what I was doing. But I had to do the far simpler method of just creating stuff in the PC's pack when the moment came.

The command for this is:

create_item_in_inventory(item #,recipiant)

Using this is relatively simple, here's a cut-down version of the one where Lila gives u her list of stuff to get:

{95}{[Lila hands you some parchment]}{[Lila hands you some parchment]}{}{}{}{create_item_in_inventory(11099,pc)}

No scripting needed in the .py file, just use it straight from the dialogue executable.

The only fiddly thing you might find is regarding the id#, if the proto number and the id# is different. Generally we do things by proto number because we tend to examine and manipulate the protos, but the id# number may differ. That is, the relevant item number may be from col 22 in Proto-Ed rather than the 'id#' column 23 which will generally match the proto number itself. Confused? Yes, its a pain, and it gets worse when trying to deal with NPCs beacuse they may have 3 different numbers Just be aware of it, and if you are making new protos, make the numbers match dagnabit!

So if you are using a script like this and it doesn't fire correctly, try using a different number. As a general rule, I would say use col 22 FIRST, and if it doesn't have a number there, add one - that is, repeat the proto number there from col 23 in col 22 (and save the protos.tab of course ;-)) If something else is already using that number somewhere, then you will get something different showing up when the transfer happens and you will know that is what the problem is :-) Then you have the painful job of trying to come up with a new number thats not used by anything else but is still somehow relevant to the item u r using. Try the search function in Proto-Ed to find a spare number, and have fun! ;-)

Could you just use give #### instead at this point? No you can't - Hazelnut proved that for us. Thanks dude!

What about transfering from the PC to the NPC? Now, that bit definitely works, thats how we moved all that crap you collected for Lila over to her. Lets have a look at it in action:

{148}{So what do you have for me?}{So what do you have for me?}{}{}{}{}
{150}{Bottle from Glora.}{}{1}{anyone( pc.group_list(), "has_item", 12892)}{174}{party_transfer_to( npc, 12892 )}
{151}{Hemlock.}{}{1}{anyone( pc.group_list(), "has_item", 5800 ) and game.global_flags[697] != 1}{160}{party_transfer_to( npc, 5800 )}
{152}{Eye of newt.}{}{1}{anyone( pc.group_list(), "has_item", 12897)}{162}{party_transfer_to( npc, 12897 )}
{153}{Bat's wing.}{}{1}{anyone( pc.group_list(), "has_item", 12896)}{164}{party_transfer_to( npc, 12896 )}
{154}{Your small cauldron.}{}{1}{anyone( pc.group_list(), "has_item", 12894)}{166}{party_transfer_to( npc, 12894 )} // Mabel
{155}{Your curette.}{}{1}{anyone( pc.group_list(), "has_item", 12895)}{168}{party_transfer_to( npc, 12895 ); schedule_reward(npc,pc)} // Morgause
{156}{Your distilling apparatus.}{}{1}{anyone( pc.group_list(), "has_item", 12893)}{170}{party_transfer_to( npc, 12893 )} // Sunom
{157}{Your crystal skull.}{}{1}{anyone( pc.group_list(), "has_item", 12898)}{172}{party_transfer_to( npc, 12898 )}
{158}{I'll just get on back to work.}{}{8}{}{0}{}
{159}{Me keep looking.}{}{-7}{}{0}{}

Here's a couple new commands:

anyone( pc.group_list(), "has_item", ####

Thats incredibly handy, makes sure you don't have to have the item in the inventory of the person doing the talking, which is annoying for the player (though you CAN do it by specific party member if it is called for, different command). The other one is our transfer command:

party_transfer_to( npc, #### )

Simple, init?

While we're describing transfering, lets have a look at the scripts that didn't work for me but do work elsewhere in the game. Again, I couldn't get them working but that may be because I wasn't properly putting things in the inventories (NPCs spawned by a mob rather than a script will have their inventories mobbed in, not from InvenSource.mes. I couldn't do that at the time). Now, as with other things, there is more than one way to do it. I tried by a couple different methods, one of which was the one Liv used to transfer stuff, and I wrote to her asking for advice and asking why she used that specific script rather than another one. Unfortunately I am such a spammer (you may have noticed) that I have long since deleted her reply (I have to keep deleting my PMs or they would go over 100 very quickly) but the gist of it was, you use what works and don't worry if there are 6 other ways to do it, if what u r doing works, then do it. Sensible girl :-)

So for starters lets look at the stuff for tranfering items from the NPC followers when you buy their starting gear. This is very handy since it deals with getting rid of items as well. Note this is NOT a transfer per se, as you will see:

def equip_transfer( attachee, triggerer ):
________itemA = attachee.item_find(6011)
________if (itemA != OBJ_HANDLE_NULL):
________________itemA.destroy()
________________create_item_in_inventory( 6011, triggerer )
________itemB = attachee.item_find(6016)
________if (itemB != OBJ_HANDLE_NULL):
________________itemB.destroy()
________________create_item_in_inventory( 6016, triggerer )
________create_item_in_inventory( 7001, attachee )
________return RUN_DEFAUL

You will quickly recognise what is happening here is the item is being destroyed in the NPC's inventory (in this case, Elmo) and recreated in the triggerer's inventory (the PC). Then, Elmo gets some money - item 7001 - created in his inventory, where it has already been removed from the PC's possession in the dialogue using one of the scripts we have seen before, pc.money_adj(-500).

Why destroy and recreate? Well, its Elmo's stuff, you can't just transfer it! The game will resist a transfer just as it resists you trying to drag and drop from their inventory to yours. For another example: I had a funny situation (also noticed by others) where Furnok looted GKR's head. Now, when I went to talk to Glora, she did the anyone( pc.group_list(), "has_item", ####) business, saw it in Furnok's inventory, and we carried on quite happily, she gave me the bottle. BUT when I checked Furnok, he still had the head! Because he had resisted the transfer - in this case, the game had simply carried on and ignored this script since it couldn't be executed.

Anyways, I threw in that about Elmo to explain this and so you could see item.destroy() in action: its a simple enough command you use to get rid of something when u r fininshed with it. But what about a real NPC - PC transfer? Well, Black Jay does one:

{140}{Oh, please please let me have it. I will trade you for it! I have magic +1 arrows, elven boots or an elven cloak.}{Oh, please please let me have it. I will trade you for it! I have magic +1 arrows, elven boots or an elven cloak.}{}{}{}{game.quests[4].state = qs_accepted}
{141}{Give me the +1 arrows.}{}{1}{}{150}{party_transfer_to( npc, 3000 ); npc.item_transfer_to_by_proto(pc,5006); game.quests[4].state = qs_completed; npc.reaction_adj( pc,15)}
{142}{Give me the boots of elvenkind.}{}{1}{}{150}{party_transfer_to( npc, 3000 ); npc.identify_all(); npc.item_transfer_to_by_proto(pc,6057); game.quests[4].state = qs_completed; npc.reaction_adj( pc,15)}
{143}{Give me the cloak of elvenkind.}{}{1}{}{150}{party_transfer_to( npc, 3000 ); npc.identify_all(); npc.item_transfer_to_by_proto(pc,6058); game.quests[4].state = qs_completed; npc.reaction_adj( pc,15)}
{144}{You can just have it.}{}{8}{}{150}{party_transfer_to( npc, 3000 ); game.quests[4].state = qs_completed; npc.reaction_adj( pc,30)}
{145}{I don't want to trade it.}{}{8}{}{160}{}
{146}{Here, you take for free.}{}{-7}{}{150}{pc.item_transfer_to(npc,3000); game.quests[4].state = qs_completed; npc.reaction_adj( pc,30)}

Notice a couple things about this. Firstly, it uses BOTH party_transfer_to( npc, #### ) and pc.item_transfer_to(npc,3000). Why different commands? I'm sure I don't know, but be aware, again, there are different ways of doing things.

The actual NPC - PC transfer is a fabulous command:

npc.item_transfer_to_by_proto(pc,####)

No frigging around with id #'s here - it tells you straight up it is dealing with the proto number itself. Hooray! Gotta be happy with that.

Also, notice something subtle: npc.identify_all() before handing over the Elven boots or cloak. So when u get it, it is already identified, doesn't just turn up as a 'magic cloak' since u should already know what it is. Nice touch.

Ok, that'll have to do for the moment, I have to pack my bag! Enjoy.

0 Comments:

Post a Comment

<< Home