Usecode Order Execution?
Posted: Sat Jun 25, 2016 9:02 pm
I am trying to get the guard on the western entrance of Skullcrusher to be "alive" rather than just standing there Waiting. There is existing code for him that asks if you have a Medallion of Order, which the item doesn't exist in the game, so he attacks.
His starting Current Activity is Waiting, and his schedule is set to repeat this at 6AM (Dawn) each day, so the only way to talk to him is cheat via F2.
So my goals for this bit of code are to:
1) Change his schedule so he's not stuck in Waiting but always in StandThere.
2) Trigger him to approach the Avatar when the gate is opened.
3) Then use the existing Usecode to bark and talk to the Avatar using the existing conversation text.
I'm running into a number of problems trying to get this to work. I've even submitted a bug for some parts of it.
My code is below. What I'm seeing is the schedule change does not take place per Flag 3 being set, but only when I double-click on the NPC. If I'm reading the code right, shouldn't that happen without needing to double-click on him? Is there a way to do this without checking any flags short of editing the map?
I haven't set the StartedTalking event, but shouldn't that be handled by the existing Usecode here?
The Proximity doesn't seem to work, I can walk the Avatar in circles around him and he doesn't change.
I had also tried to get an event that causes him to recognize when the sliding door is opened. The game uses two shapes for this. The closed and opening door is Shape 303, but the fully-opened door is Shape 936, frame 1. In both cases the Quality is 91. Nothing that I've tried for this has worked either.
His starting Current Activity is Waiting, and his schedule is set to repeat this at 6AM (Dawn) each day, so the only way to talk to him is cheat via F2.
So my goals for this bit of code are to:
1) Change his schedule so he's not stuck in Waiting but always in StandThere.
2) Trigger him to approach the Avatar when the gate is opened.
3) Then use the existing Usecode to bark and talk to the Avatar using the existing conversation text.
I'm running into a number of problems trying to get this to work. I've even submitted a bug for some parts of it.
My code is below. What I'm seeing is the schedule change does not take place per Flag 3 being set, but only when I double-click on the NPC. If I'm reading the code right, shouldn't that happen without needing to double-click on him? Is there a way to do this without checking any flags short of editing the map?
I haven't set the StartedTalking event, but shouldn't that be handled by the existing Usecode here?
The Proximity doesn't seem to work, I can walk the Avatar in circles around him and he doesn't change.
Code: Select all
void Guard17 object#(0x4be) () // Automaton at entrance, NPC 190, Guard17, should talk when gate is opened. Flag 613 to test.
// Door open = Shape 936, sliding door frame 1, Quality 91. Non-open door is 303, same quality
{
if (gflags[STARTING_SPEECH]) // Need an event here to check, this is flag is set automatically during the opening sequence.
UI_set_new_schedules(GUARD17, DAWN, STANDTHERE, [0x03C2, 0x0415]); // Replaces Waiting schedule with same for StandThere at 0962, 1045.
{
if (event == DOUBLECLICK)
{
UI_set_schedule_type(GUARD17, TALK);
//delayedBark(GUARD17, "@Halt! Intruder!@", 0); // Existing Origin Usecode already handles this.
gflags[FOUND_FISHNETS] = true; // Testing only.
}
if (event == PROXIMITY)
{
UI_set_schedule_type(GUARD17, TALK);
//delayedBark(GUARD17, "@Halt! Intruder!@", 0); // Existing Origin Usecode already handles this.
gflags[FOUND_FISHNETS] = true; // Testing only.
}
}
Guard17.original(); // His existing speech is well-done by Origin.
}