Skip to content

Commit

Permalink
* Started work on using dream machine
Browse files Browse the repository at this point in the history
  • Loading branch information
yuv422 committed Feb 2, 2017
1 parent 2f203eb commit 2b1d3cf
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
@@ -1,3 +1,6 @@
2017-02-02 Eric Fry <efry at users.sourceforge.net>
* Started work on using dream machine

2017-02-01 Eric Fry <efry at users.sourceforge.net>
* Added MD use headgear
* Work on MD use panel
Expand Down
9 changes: 9 additions & 0 deletions data/scripts/md/actor.lua
Expand Up @@ -1517,6 +1517,15 @@ function actor_hit(actor, damage)
end
end

function kill_actor(actor)
actor.hp=0
actor_dead(actor)
end

function actor_dead(actor)
--FIXME
end

function get_portrait_number(actor)
local NO_PORTRAIT = 255
local idx = actor.actor_num
Expand Down
24 changes: 24 additions & 0 deletions data/scripts/md/dreamworld.lua
Expand Up @@ -5,3 +5,27 @@ function wake_from_dream()
end


function actor_use_dream_machine(actor, dream_quality)
if actor.actor_num ~= 1 then
--FIXME advance time till dawn.
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

dream_actor.obj_n = actor.obj_n
dream_actor.frame_n = actor.frame_n

Actor.move(dream_actor, dream_x, dream_y, 2)
player_set_actor(dream_actor)

end

end
1 change: 1 addition & 0 deletions data/scripts/md/lang/en/game.lua
Expand Up @@ -233,4 +233,5 @@ STATUS_LIGHTS_CHANGE_BUT_YOU_SEE_NO_OTHER_EFFECT="Status lights change but you s
YOU_ACTUATE_THE_MECHANISM_TO_NO_APPARENT_EFFECT="You actuate the mechanism to no apparent effect.\n",
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",
}
54 changes: 49 additions & 5 deletions data/scripts/md/usecode.lua
Expand Up @@ -1614,11 +1614,12 @@ function use_dream_machine(panel_obj)
return
end

local z = panel_obj.z
local power_unit
local dream_quality
local headgear_installed = false
local seat_x, seat_y
for obj in find_obj_from_area(panel_obj.x - 5, panel_obj.y - 5, panel_obj.z, 11, 11) do
for obj in find_obj_from_area(panel_obj.x - 5, panel_obj.y - 5, z, 11, 11) do
local obj_n = obj.obj_n
if obj_n == 290 and obj.frame_n == 1 then --OBJ_POWER_UNIT
power_unit = obj
Expand All @@ -1632,16 +1633,59 @@ function use_dream_machine(panel_obj)
end
end

local actor_in_seat = map_get_actor(seat_x, seat_y, panel_obj.z)
local actor_in_seat = map_get_actor(seat_x, seat_y, z)

if power_unit == nil or dream_quality == nil or not headgear_installed then
printl("THE_MACHINE_DOES_NOT_WORK")
return
end

local martian = map_get_obj(seat_x, seat_y, panel_obj.z, 291) --OBJ_UNCONSCIOUS_MARTIAN
if martian ~= nil then
--FIXME
local martian_obj = map_get_obj(seat_x, seat_y, z, 291) --OBJ_UNCONSCIOUS_MARTIAN
if martian_obj ~= nil then
if Actor.get_talk_flag(0x21, 2) or not Actor.get_talk_flag(0x61, 4) then
printl("IT_HAS_NO_EFFECT")
else
play_midgame_sequence(5)
local martian = Actor.get(0x21)
Actor.talk(martian)
Actor.set_talk_flag(martian, 2)
martian.x = seat_x
martian.y = seat_y + 1
martian.z = panel_obj.z
kill_actor(martian)
Obj.removeFromEngine(martian_obj)
end

return
end

local metal_woman_obj = map_get_obj(seat_x, seat_y, z, 287) --OBJ_METAL_WOMAN
if metal_woman_obj ~= nil then
if metal_woman_obj.quality == 0 then
printl("IT_HAS_NO_EFFECT")
else
--FIXME implement metal woman activation logic
end
elseif actor_in_seat ~= nil then
if z ~= 0 then
wake_from_dream()
else
if dream_quality < 2 then
Actor.set_talk_flag(0x60, 3)
end
if dream_quality == 3 then
if Actor.get_talk_flag(0x46, 0) then
--FIXME call sub_3F624
else
printl("THE_MACHINE_DOES_NOT_WORK")
end
else
actor_use_dream_machine(actor_in_seat, dream_quality)
end

end
else
printl("THERE_IS_NOBODY_SITTING_IN_THE_MACHINE")
end

end
Expand Down

0 comments on commit 2b1d3cf

Please sign in to comment.