@@ -688,20 +688,59 @@ impl GameState {
688688 // return 0;
689689 // }
690690
691- let used_kind = {
691+ let ( used_kind, script ) = {
692692 let world = self . world . borrow ( ) ;
693693 let usedo = world. objects ( ) . get ( used) ;
694- if let Some ( ExactEntityKind :: Scenery ( v) ) = usedo. proto ( ) . map ( |p| p. kind ( ) ) {
695- v
696- } else {
697- return ;
698- }
694+ let used_kind = unwrap_or_return ! (
695+ usedo. proto( ) . map( |p| p. kind( ) ) ,
696+ Some ( ExactEntityKind :: Scenery ( v) ) => v) ;
697+ ( used_kind, usedo. script )
699698 } ;
700699
701700 if used_kind == SceneryKind :: Door {
702701 self . use_door ( user, used, ui) ;
703702 } else {
704- // TODO
703+ let world = & mut self . world . borrow_mut ( ) ;
704+
705+ let script_overrides = if let Some ( ( sid, _) ) = script {
706+ self . scripts . execute_predefined_proc ( sid, PredefinedProc :: Use ,
707+ & mut script:: Context {
708+ world,
709+ sequencer : & mut self . sequencer ,
710+ dialog : & mut self . dialog ,
711+ ui,
712+ message_panel : self . message_panel ,
713+ map_id : self . map_id . unwrap ( ) ,
714+ source_obj : Some ( user) ,
715+ target_obj : Some ( used) ,
716+ } ) . unwrap ( ) . assert_no_suspend ( ) . script_overrides
717+ } else {
718+ false
719+ } ;
720+ let script_overrides = if !script_overrides {
721+ match used_kind {
722+ SceneryKind :: Door => unreachable ! ( ) ,
723+ // TODO
724+ | SceneryKind :: Stairs
725+ | SceneryKind :: Elevator
726+ | SceneryKind :: LadderDown
727+ | SceneryKind :: LadderUp
728+ => {
729+ warn ! ( "{:?} use is not implemented" , used_kind) ;
730+ false
731+ }
732+ SceneryKind :: Misc => false ,
733+ }
734+ } else {
735+ false
736+ } ;
737+ if !script_overrides && user == world. dude_obj ( ) . unwrap ( ) {
738+ if let Some ( obj_name) = world. object_name ( used) {
739+ let msg = & self . proto_db . messages ( ) . get ( MSG_YOU_SEE_X ) . unwrap ( ) . text ;
740+ let msg = sprintf ( msg, & [ & obj_name] ) ;
741+ self . push_message ( & msg, ui) ;
742+ }
743+ }
705744 }
706745 }
707746
0 commit comments