Skip to content

Commit

Permalink
* Don't delete MD dream teleporter objects even though
Browse files Browse the repository at this point in the history
  they are marked as temporary.
* Added party_set_in_vehicle() script function
* Fixed bug with location table argument handling in lua C logic
* Fixed bug with Weather class in MD mode.
* More work on MD dream logic
  • Loading branch information
yuv422 committed Feb 9, 2017
1 parent 2b1d3cf commit 96373e6
Show file tree
Hide file tree
Showing 12 changed files with 214 additions and 20 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
2017-02-09 Eric Fry <efry at users.sourceforge.net>
* Don't delete MD dream teleporter objects even though
they are marked as temporary.
* Added party_set_in_vehicle() script function
* Fixed bug with location table argument handling in lua C logic
* Fixed bug with Weather class in MD mode.
* More work on MD dream logic

2017-02-02 Eric Fry <efry at users.sourceforge.net>
* Started work on using dream machine

Expand Down
11 changes: 8 additions & 3 deletions ObjManager.cpp
Expand Up @@ -1906,9 +1906,14 @@ void ObjManager::temp_obj_list_clean_area(uint16 x, uint16 y)
if(dist_x > 19 || dist_y > 19)
{
tmp_obj = *obj++;
DEBUG(0,LEVEL_DEBUGGING,"Removing obj %s.\n", tile_manager->lookAtTile(get_obj_tile_num((tmp_obj)->obj_n)+(tmp_obj)->frame_n,0,false));
remove_obj_from_map(tmp_obj);
delete_obj(tmp_obj);
if(game_type != NUVIE_GAME_MD || (tmp_obj->obj_n != OBJ_MD_DREAM_TELEPORTER && tmp_obj->frame_n != 0)) { //FIXME MD has special temp object flag override logic. This should be implemented in lua script.
DEBUG(0,
LEVEL_DEBUGGING,
"Removing obj %s.\n",
tile_manager->lookAtTile(get_obj_tile_num((tmp_obj)->obj_n) + (tmp_obj)->frame_n, 0, false));
remove_obj_from_map(tmp_obj);
delete_obj(tmp_obj);
}
}
else
obj++;
Expand Down
1 change: 1 addition & 0 deletions U6objects.h
Expand Up @@ -472,6 +472,7 @@
#define OBJ_MD_DREAMSTUFF 331
#define OBJ_MD_DEAD_BODY 341
#define OBJ_MD_CHIP_OF_RADIUM 449
#define OBJ_MD_DREAM_TELEPORTER 461


#endif /* __U6objects_h__ */
5 changes: 4 additions & 1 deletion Weather.cpp
Expand Up @@ -128,8 +128,11 @@ uint8 Weather::load_wind(NuvieIO *objlist)

void Weather::clear_wind()
{
if(wind_timer)
if(wind_timer) {
wind_timer->stop_timer();
wind_timer = NULL;
}


wind_dir = NUVIE_DIR_NONE;

Expand Down
6 changes: 6 additions & 0 deletions data/scripts/md/actor.lua
Expand Up @@ -223,6 +223,12 @@ function actor_set_blue_berry_counter(new_value)
timer_set(16*3, new_value)
end

function actor_clear_berry_counters(actor_num)
timer_set(actor_num*3, 0)
timer_set(actor_num*3+1, 0)
timer_set(actor_num*3+2, 0)
end

--
-- actor_init(actor)
--
Expand Down
95 changes: 94 additions & 1 deletion data/scripts/md/dreamworld.lua
Expand Up @@ -8,24 +8,117 @@ end
function actor_use_dream_machine(actor, dream_quality)
if actor.actor_num ~= 1 then
--FIXME advance time till dawn.
printfl("ACTOR_DREAMS_UNTIL_DAWN_WHILE_THE_PARTY_WAITS", actor.name)
actor.asleep = true
g_party_is_warm = true
advance_time(60 - clock_get_minute())
while clock_get_hour() ~= 8 do
advance_time(20)
script_wait(100)
end
g_party_is_warm = false
else
play_midgame_sequence(4)
party_set_party_mode()
local dream_actor = Actor.get(0)
-- party_hide_all()

local dream_x, dream_y
if dream_quality == 1 then
dream_x, dream_y = 0x64, 0x3b
else
dream_x, dream_y = 0x93, 0x34
end

--FIXME need to copy over more data from avatar actor.
dream_actor.obj_n = actor.obj_n
dream_actor.frame_n = actor.frame_n
dream_actor.base_obj_n = actor.base_obj_n
dream_actor.wt = WT_PLAYER
dream_actor.visible = true
dream_actor.hp = actor.max_hp

Actor.move(dream_actor, dream_x, dream_y, 2)
player_set_actor(dream_actor)
party_set_in_vehicle(true)
party_hide_all()
g_in_dream_mode = true


end
end

local dreamworld_cleanup_tbl = {
[5]=function() end,
[0x20]=function() end,
[0x40]=function() end,
[0x44]=function() end,
[0xa0]=function() end,
}

local dreamworld_unk_tbl = {
[0x4]=function() end,
[0x40]=function() end,
[0x85]=function() end,
[0xA1]=function() end,
[0xA4]=function() end,
[0xC0]=function() end,
[0xC1]=function() end,
[0xC4]=function() end,
[0xC5]=function() end,
[0xE0]=function() end,
}

local dreamworld_init_tbl = {
[0x5]=function() end,
[0x20]=function() end,
[0x25]=function() end,
[0x44]=function() end,
[0x60]=function() end,
[0xA5]=function() end,
[0xC0]=function() end,
[0xC4]=function() end,
[0xC5]=function() end,
}

function dreamworld_cleanup_state(obj)
local dream_actor = Actor.get(0)
local new_stage = bit32.band(obj.status, 0xe5)
if g_current_dream_stage ~= 0 and new_stage ~= 0xa5 and new_stage ~= 0xe5 then
if dreamworld_cleanup_tbl[g_current_dream_stage] ~= nil then
dreamworld_cleanup_tbl[g_current_dream_stage]()
end

end

if new_stage == 1 then
g_current_dream_stage = 0
return
elseif new_stage == 0x24 then
wake_from_dream()
return
elseif g_current_dream_stage ~= 0 and dreamworld_unk_tbl[new_stage] ~= nil then
dreamworld_unk_tbl[new_stage]()
end

if new_stage ~= 0xa5 then
--FIXME clean up temp objects
g_objlist_1d22_unk = 0
end

actor_clear_berry_counters(dream_actor.actor_num)
local player_loc = player_get_location()
player_move(obj.quality, obj.qty, player_loc.z)

if new_stage == 0xe5 then
if not Actor.get_talk_flag(0x66, 3) then
g_objlist_1d22_unk = 6
end
else
if dreamworld_init_tbl[new_stage] ~= nil then
dreamworld_init_tbl[new_stage]()
end

g_current_dream_stage = new_stage
end

end
15 changes: 14 additions & 1 deletion data/scripts/md/init.lua
Expand Up @@ -4,9 +4,11 @@ local lua_file = nil
lua_file = nuvie_load("common/common.lua"); lua_file();

OBJLIST_OFFSET_HOURS_TILL_NEXT_HEALING = 0x1cf2
OBJLIST_OFFSET_1D22_UNK = 0x1d22
OBJLIST_OFFSET_DREAM_MODE_FLAG = 0x1d29

OBJLIST_OFFSET_BERRY_COUNTERS = 0x1d2f
OBJLIST_OFFSET_DREAM_STAGE = 0x1d53

function dbg(msg_string)
io.stderr:write(msg_string)
Expand All @@ -29,7 +31,13 @@ function load_game()

objlist_seek(OBJLIST_OFFSET_DREAM_MODE_FLAG)
g_in_dream_mode = bit32.btest(objlist_read2(), 0x10)


objlist_seek(OBJLIST_OFFSET_DREAM_STAGE)
g_current_dream_stage = objlist_read2()

objlist_seek(OBJLIST_OFFSET_1D22_UNK)
g_objlist_1d22_unk = objlist_read1()

update_watch_tile()
end

Expand All @@ -47,6 +55,11 @@ function save_game()
objlist_seek(OBJLIST_OFFSET_DREAM_MODE_FLAG)
objlist_write2(bytes)

objlist_seek(OBJLIST_OFFSET_DREAM_STAGE)
objlist_write2(g_current_dream_stage)

objlist_seek(OBJLIST_OFFSET_1D22_UNK)
objlist_write1(g_objlist_1d22_unk)
end


Expand Down
1 change: 1 addition & 0 deletions data/scripts/md/lang/en/game.lua
Expand Up @@ -234,4 +234,5 @@ YOU_ACTUATE_THE_MECHANISM_TO_NO_APPARENT_EFFECT="You actuate the mechanism to no
THE_DREAM_MACHINES_SEEM_TO_HAVE_CEASED_FUNCTIONING="The dream machines seem to have ceased functioning.\n",
THE_MACHINE_DOES_NOT_WORK="The machine does not work.\n",
THERE_IS_NOBODY_SITTING_IN_THE_MACHINE="There is nobody sitting in the machine.\n",
ACTOR_DREAMS_UNTIL_DAWN_WHILE_THE_PARTY_WAITS="%s dreams until dawn while the party waits.\n",
}
17 changes: 16 additions & 1 deletion data/scripts/md/player.lua
Expand Up @@ -17,7 +17,7 @@ local map_entrance_tbl = {
{x=0x34C, y=0x25A, z=0x0},
{x=0x7C, y=0x28, z=0x4},
{x=0x13E, y=0x118, z=0x0},
{x=0x0A, y=0x60, z=0x5},
{x=0x0A, y=0x61, z=0x5},
{x=0x3B7, y=0x1C4, z=0x0},
{x=0x5C, y=0x0B1, z=0x5},
{x=0x3DC, y=0x1DD, z=0x0},
Expand Down Expand Up @@ -181,6 +181,21 @@ function player_post_move_action(did_move)
party_use_entrance(player_loc.x, player_loc.y, player_loc.z, map_entrance_tbl[obj.quality])
elseif obj_n == 461 then --OBJ_DREAM_TELEPORTER
--FIXME add logic here.
local obelisk = map_get_obj(player_loc.x, player_loc.y - 1, player_loc.z, 292, true)
if obelisk ~= nil then
--FIXME fade here.
end
local dream_actor = Actor.get(0)
if bit32.band(obj.status, 0xe5) ~= 0xa5 or dream_actor.hp > 4 then
if bit32.band(obj.status, 0xe5) == 0 then
player_move(obj.quality, obj.qty, player_loc.z)
advance_time(0)
else
dreamworld_cleanup_state(obj)
end

end

end
end
else
Expand Down
28 changes: 27 additions & 1 deletion ldoc/index.html
Expand Up @@ -338,6 +338,10 @@ <h2><a href="#party">party</a></h2>
<td class="summary">Dismount all party members from their horses (U6)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#party_set_in_vehicle">party_set_in_vehicle (value)</a></td>
<td class="summary">Toggle party vehicle mode</td>
</tr>
<tr>
<td class="name" nowrap><a href="#party_show_all">party_show_all ()</a></td>
<td class="summary">Show all party members on the map.</td>
</tr>
Expand Down Expand Up @@ -1494,7 +1498,7 @@ <h3>Fields:</h3>
</li>
<li><span class="parameter">status</span>
<span class="types"><span class="type">int</span></span>
Object status <em>writeonly</em>
Object status
</li>
<li><span class="parameter">invisible</span>
<span class="types"><span class="type">bool</span></span>
Expand Down Expand Up @@ -2588,6 +2592,28 @@ <h3>Parameters:</h3>



</dd>
<dt>
<a name = "party_set_in_vehicle"></a>
<strong>party_set_in_vehicle (value)</strong>
</dt>
<dd>
Toggle party vehicle mode


<h3>Parameters:</h3>
<ul>
<li><span class="parameter">value</span>
<span class="types"><span class="type">bool</span></span>


</li>
</ul>





</dd>
<dt>
<a name = "party_show_all"></a>
Expand Down

0 comments on commit 96373e6

Please sign in to comment.