Page 1 of 1
I think my mod broke something...
Posted: Mon Dec 05, 2011 6:11 pm
by Crowley
This is bizarre. For some reason I cannot talk to NPCs in the range of 149-187 in my mod. Usually nothing happens if I double-click on them or press T and then click the crosshairs on them. Sometimes the pointer will turn into the hand, and the party freezes in place (occasionally exclaiming "I am frozen in place!"), but the dialogue does not begin. As mentioned, this only affects a specific range of NPCs with sequential numbering. I can send my mod files for anyone who wants to test this out themselves.
Re: I think my mod broke something...
Posted: Mon Dec 05, 2011 9:39 pm
by marzo
It may be that you are overwriting the usecode functions of those NPCs. NPC usecode for NPCs 1-256 is 0x400 + NPC number; other NPCs need to have their usecode set by ES or by set_usecode_fun intrinsic.
For shapes, their usecode functions have to be defined as
where shapeid is the shape number. Using only shapeid instead of shape#(shapeid) not only would overwrite NPC usecode, but it also won't work in Exult.
Re: I think my mod broke something...
Posted: Mon Dec 05, 2011 10:35 pm
by Crowley
At least renaming the mod's usecode file so that the game doesn't use it fixed the problem. I've been going through my custom usecode, and I am not certain what the problem is. There's not much of it, so I guess it wouldn't be too much to post here:
Code: Select all
#include "headers/constants.uc" //standard constant definitions
#include "headers/constants2.uc" //standard constant definitions
#include "headers/bg/bg_npcs.uc" //Black Gate npc constants
#include "headers/npcs.uc" //New npc constants
#include "headers/bg/bg_shapes.uc" //Black Gate shape and frame constants
#include "headers/bg/bg_shapes2.uc" //Black Gate shape and frame constants
#include "headers/new_shapes.uc" //Brand new shape and frame constants
#include "headers/bg/bg_gflags.uc" //Black Gate global flags
#include "headers/bg/bg_gflags2.uc" //Black Gate global flags
#include "headers/new_flags.uc" //Brand new global flags
#include "headers/bg/bg_externals.uc" //extern declarations for BG functions
#include "headers/bg/bg_externals2.uc" //extern declarations for BG functions
#include "headers/new_items.uc" //extern declarations for new items
#include "headers/functions.uc" //new general-purpose functions
#include "headers/functions2.uc" //Some new general-purpose functions
#include "headers/array_functions.uc" //Several array functions
void turnKey ()
{
var target_frame = item->get_item_frame();
if (((target_frame + 1) % 4) == 0)
{
script AVATAR
{ actor frame 3; wait 2; actor frame standing; }
UI_play_sound_effect(SOUND_KEY);
var unlock_frame = (target_frame - 3);
item->set_item_frame(unlock_frame);
return;
}
else
{
script AVATAR
{ actor frame 3; wait 2; actor frame standing; }
randomPartyBark("@The key does not fit.@");
return;
}
}
void SkullKey shape#(0x400) ()
{
if (event == DOUBLECLICK)
{
UI_close_gumps();
var target = UI_click_on_item();
if (!target)
{
randomPartyBark("@There is no lock on that.@");
return;
}
var target_coords = getClickPosition(target);
var lock_shapes = [SHAPE_DOOR_HORIZONTAL, SHAPE_DOOR_VERTICAL, SHAPE_DOOR2_HORIZONTAL, SHAPE_DOOR2_VERTICAL, SHAPE_CHEST, SHAPE_LOCKED_CHEST];
var target_shape = target->get_item_shape();
var target_frame = target->get_item_frame();
if (!(UI_is_dest_reachable(AVATAR, target_coords)))
{
UI_flash_mouse(2);
return;
}
else if (target_shape in lock_shapes)
{
UI_si_path_run_usecode(AVATAR, target_coords, false, target, turnKey, false);
return;
}
else
{
randomPartyBark("@There is no lock on that.@");
return;
}
}
}
void RubberDucky shape#(0x401) ()
{
if (event == DOUBLECLICK)
{
item->item_say("Squeak!");
return;
}
}
void HornOfPlenty shape#(0x402) ()
{
if (event == DOUBLECLICK)
{
var target = UI_click_on_item();
var party = UI_get_party_list();
if (!target)
{
UI_flash_mouse(1);
return;
}
else if (!(target in party))
{
UI_flash_mouse(1);
return;
}
else
{
var targetfood = (target->get_npc_prop(9));
if (targetfood > 24)
{
target->item_say("@No, thank thee.@");
return;
}
else
{
target->set_npc_prop(9, (31-targetfood));
target->item_say("@Ahh, I am full now.@");
return;
}
}
}
}
void ChaosSword shape#(0x403) ()
{
var wielder = UI_get_container(ChaosSword);
if (event == WEAPON)
{
wielder->set_item_flag(2);
return;
}
else if (event == READIED)
{
wielder->set_item_flag(2);
UI_set_attack_mode(wielder, 0);
return;
}
}
void Dupre object#(0x404) ()
{
item.say("@Nice rubber ducky thou dost have there!@");
Dupre.original();
}
That last bit was me trying to figure out how to append existing conversations. One additional oddity is that when around the affected NPCs, party members would sometimes bark "The key does not fit." without prompting.
Re: I think my mod broke something...
Posted: Mon Dec 05, 2011 10:48 pm
by marzo
Are there any warnings printed by UCC when you compile usecode?
Also, if they are not already there, add the following lines before the first include:
Code: Select all
#game "blackgate"
#autonumber 0xC00
and then checking if the problem persists?
Also, it is good to see that
someone is using all the work I put on making those header files
Re: I think my mod broke something...
Posted: Tue Dec 06, 2011 9:55 am
by Crowley
The auto-numbering squashed the bug. Without it, compiling the usecode produced a mass of error messages saying "Warning: Auto-numbering function 'xxxx', but '#autonumber' directive not used." Thank thee kindly!
By the way, if you haven't gotten around to adding to your keyring mod the double-click support for LB's sceptre, I think my skull key code could be applied there with minor modifications. I'm not sure if it would make the Avatar actually step into the magic fields, though.
Re: I think my mod broke something...
Posted: Tue Dec 06, 2011 4:58 pm
by agentorangeguy
Marzo, where are those particular header files located? I think I must have an older version of them.
Re: I think my mod broke something...
Posted: Tue Dec 06, 2011 5:02 pm
by marzo
In the Exult source, go to content/bgkeyring/src/headers.
Re: I think my mod broke something...
Posted: Wed Dec 07, 2011 12:30 am
by Crowley
To be honest, I included those headers without really knowing what they contain, because they were there in custom usecode I used as an example to follow. <_<