Commit b175a4e8 authored by auraes's avatar auraes 💬
Browse files

Mise à jour Puny 0672152

parent ca18d013
......@@ -28,6 +28,7 @@ Constant OPTIONAL_NO_DARKNESS;
!Constant OPTIONAL_SHIP_DIRECTIONS;
!Constant OPTIONAL_GUESS_MISSING_NOUN;
!Constant OPTIONAL_MANUAL_SCOPE;
!Constant OPTIONAL_MANUAL_REACTIVE;
!Constant OPTIONAL_ORDERED_TIMERS;
!Constant OPTIONAL_PROVIDE_UNDO;
!Constant RUNTIME_ERRORS = 0;
......
......@@ -110,6 +110,7 @@ Attribute door;
Attribute locked;
Attribute lockable;
Attribute workflag;
Attribute reactive;
! when you order a NPC, but the command isn't understood
......@@ -488,6 +489,8 @@ Global also_flag; ! Used by Look
Global inventory_stage;
Global phase2_necessary;
Global receive_action;
Global scope_copy_actor;
Global scope_copy_is_good = false;
!FRENCH
#IfV3;
......
......@@ -1451,6 +1451,10 @@ Verb meta 'tree'
Verb meta 'gonear'
* noun -> GoNear;
Verb meta 'debug'
* -> Debug
* 'reactive' -> Debug;
Verb meta 'routines' 'messages'
* -> RoutinesOn
* 'on' -> RoutinesOn
......@@ -1532,7 +1536,7 @@ Global scope_cnt;
TreeSubHelper(_obj, 1);
];
[TreeSubHelper p_parent p_indent _x _i;
[ TreeSubHelper p_parent p_indent _x _i;
objectloop(_x in p_parent) {
for(_i = 0 : _i < p_indent : _i++) print " ";
print (name) _x, "^";
......@@ -1540,6 +1544,32 @@ Global scope_cnt;
}
];
[ DebugSub _w _o;
wn = num_words;
_w = NextWord();
switch(_w) {
'reactive':
#Ifndef OPTIONAL_MANUAL_REACTIVE;
_o = 1;
"Define OPTIONAL_MANUAL_REACTIVE and recompile.";
#Ifnot;
print "Give reactive to these objects:^";
objectloop(_o)
if(_o hasnt reactive && (_o.&react_before ~= 0 ||
_o.&react_after ~= 0 || _o.&each_turn ~= 0))
print "(",_o,") ", (name) _o, "^";
print "^Remove reactive from these objects:^";
objectloop(_o)
if(_o has reactive && _o.&react_before == 0 &&
_o.&react_after == 0 && _o.&each_turn == 0)
print "(",_o,") ", (name) _o, "^";
#Endif;
default:
"Type one of the following:^
DEBUG REACTIVE";
}
];
[ RoutinesOnSub; debug_flag = debug_flag | 1; "[Message listing on.]"; ];
[ RoutinesOffSub; debug_flag = debug_flag & 14; "[Message listing off.]"; ];
......
......@@ -1449,6 +1449,10 @@ Verb meta 'tree'
Verb meta 'gonear'
* noun -> GoNear;
Verb meta 'debug'
* -> Debug
* 'reactive' -> Debug;
Verb meta 'routines' 'messages'
* -> RoutinesOn
* 'on' -> RoutinesOn
......@@ -1530,7 +1534,7 @@ Global scope_cnt;
TreeSubHelper(_obj, 1);
];
[TreeSubHelper p_parent p_indent _x _i;
[ TreeSubHelper p_parent p_indent _x _i;
objectloop(_x in p_parent) {
for(_i = 0 : _i < p_indent : _i++) print " ";
print (name) _x, "^";
......@@ -1538,6 +1542,32 @@ Global scope_cnt;
}
];
[ DebugSub _w _o;
wn = num_words;
_w = NextWord();
switch(_w) {
'reactive':
#Ifndef OPTIONAL_MANUAL_REACTIVE;
_o = 1;
"Define OPTIONAL_MANUAL_REACTIVE and recompile.";
#Ifnot;
print "Give reactive to these objects:^";
objectloop(_o)
if(_o hasnt reactive && (_o.&react_before ~= 0 ||
_o.&react_after ~= 0 || _o.&each_turn ~= 0))
print "(",_o,") ", (name) _o, "^";
print "^Remove reactive from these objects:^";
objectloop(_o)
if(_o has reactive && _o.&react_before == 0 &&
_o.&react_after == 0 && _o.&each_turn == 0)
print "(",_o,") ", (name) _o, "^";
#Endif;
default:
"Type one of the following:^
DEBUG REACTIVE";
}
];
[ RoutinesOnSub; debug_flag = debug_flag | 1; "[Message listing on.]"; ];
[ RoutinesOffSub; debug_flag = debug_flag & 14; "[Message listing off.]"; ];
......
......@@ -163,6 +163,15 @@ Constant MSG_FULLSCORE_ROOMS "lieu(x) visité(s)"; !FIXME
#Ifndef MSG_FULLSCORE_ACTIONS;
Constant MSG_FULLSCORE_ACTIONS "action(s) importante(s) effectuée(s)"; !FIXME
#EndIf;
#Ifndef MSG_PARSER_CANT_OOPS;
Constant MSG_PARSER_CANT_OOPS "Désolé, il est impossible de corriger.";
#EndIf;
#Ifndef MSG_PARSER_COMPLEX_AGAIN;
Constant MSG_PARSER_COMPLEX_AGAIN "La commande Encore doit se trouver sur une nouvelle ligne de saisie.^"; !FIXME
#EndIf;
#Ifndef MSG_PARSER_NOTHING_TO_AGAIN;
Constant MSG_PARSER_NOTHING_TO_AGAIN "Vous ne pouvez pas répéter cela.";
#EndIf;
#EndIf;
!
! complex messages (enumerated)
......@@ -296,6 +305,7 @@ Default MSG_INSERT_NOT_CONTAINER 118;
Default MSG_EMPTY_CANT_CONTAIN 119; ! Extended verbset, but uses same msg as INSERT
Default MSG_YES_OR_NO 120;
Default MSG_RESTART_CONFIRM 121;
Default MSG_PARSER_NEW_SCORE 122;
#IfDef OPTIONAL_PROVIDE_UNDO_FINAL;
#Ifndef MSG_UNDO_NOTHING_DONE;
......@@ -703,6 +713,20 @@ MSG_RUB_DEFAULT, MSG_SQUEEZE_DEFAULT:
MSG_RESTART_CONFIRM:
print "Êtes-vous sûr de vouloir recommencer ? ";
#Endif;
#IfTrue MSG_PARSER_NEW_SCORE < 1000;
MSG_PARSER_NEW_SCORE:
print "^[Votre score vient ";
if(p_arg_1 < score) {
p_arg_2 = score - p_arg_1;
print "d'augmenter";
} else {
p_arg_2 = p_arg_1 - score;
print "de diminuer";
}
print " de ", p_arg_2, " point";
if(p_arg_2 > 1) print "s";
print ".]^";
#Endif;
#IfDef OPTIONAL_EXTENDED_VERBSET;
#IfTrue MSG_BLOW_DEFAULT < 1000;
......
......@@ -1537,10 +1537,14 @@ Array guess_num_objects->5;
if(_best_phase2 == PHASE2_ERROR) {
! call again to generate suitable error message
_score = _ParsePattern(_best_pattern, PHASE2);
} else {
rtrue;
} else if(_best_phase2 == PHASE2_DISAMBIGUATION) {
PrintMsg(MSG_PARSER_NOSUCHTHING);
rtrue;
}
rtrue;
! if not ERROR or DISAMBIGUATION, then we are currently
! parsning a filter command such as scope=ScopeRoutine,
! which we should allow to fall through into PHASE2
}
! Phase 2: reparse best pattern and ask for additional info if
......
......@@ -465,9 +465,13 @@ else
}
];
[ _InitFloatingObjects _i _k _stop;
[ _InitObjects _i _k _stop;
_stop = top_object + 1;
for(_i = Directions : _i < _stop : _i++) {
#Ifndef OPTIONAL_MANUAL_REACTIVE;
if(_i.&react_before ~= 0 || _i.&react_after ~= 0 || _i.&each_turn ~= 0)
give _i reactive;
#Endif;
if(_i.&found_in) {
#IfTrue RUNTIME_ERRORS > RTE_MINIMUM;
if(_k >= MAX_FLOATING_OBJECTS) {
......@@ -622,20 +626,23 @@ Include "parser.h";
return false; ! failed to run (stopped by BeforeRoutines)
];
[ RunEachTurn _i _obj _scope_count;
[ RunEachTurn _i _obj _scope_count _max;
! Run all each_turn routines for location and all objects in scope.
#IfDef DEBUG;
if(debug_flag & 1 && location.&each_turn ~= 0) print "(", (name) location, ").each_turn()^";
if(debug_flag & 1 && location has reactive && location.&each_turn ~= 0) print "(", (name) location, ").each_turn()^";
#EndIf;
#Ifndef OPTIONAL_MANUAL_SCOPE;
scope_modified = true;
#EndIf;
_scope_count = GetScopeCopy();
RunRoutines(location, each_turn);
for(_i = 0: _i < _scope_count: _i++) {
if(_scope_count) {
_max = _scope_count - 1;
.next_entry;
if(deadflag >= GS_DEAD) rtrue;
_obj = scope_copy-->_i;
if(_obj.&each_turn ~= 0) {
if(_obj has reactive && _obj.&each_turn ~= 0) {
#IfDef DEBUG;
if(debug_flag & 1) print "(", (name) _obj, ").each_turn()^";
#EndIf;
......@@ -645,10 +652,11 @@ Include "parser.h";
#EndIf;
RunRoutines(_obj, each_turn);
}
@inc_chk _i _max ?~next_entry;
}
];
[ BeforeRoutines _i _obj _scope_count;
[ BeforeRoutines _i _obj _scope_count _max;
! react_before - Loops over the scope to find possible react_before routines
! to run in each object, if it's found stop the action by returning true
#IfnDef OPTIONAL_MANUAL_SCOPE;
......@@ -671,9 +679,11 @@ Include "parser.h";
#EndIf;
if(RunRoutines(player, orders)) rtrue;
for(_i = 0: _i < _scope_count: _i++) {
if(_scope_count) {
_max = _scope_count - 1;
.next_entry;
_obj = scope_copy-->_i;
if (_obj provides react_before) {
if (_obj has reactive && _obj.&react_before ~= 0) {
#IfDef DEBUG;
if(debug_flag & 1) print "(", (name) _obj, ").react_before()^";
#EndIf;
......@@ -685,11 +695,12 @@ Include "parser.h";
rtrue;
}
}
@inc_chk _i _max ?~next_entry;
}
#IfDef DEBUG;
if(debug_flag & 1) print "(", (name) location, ").before()^";
#EndIf;
if(location provides before) {
if(location.&before) {
#Ifndef OPTIONAL_MANUAL_SCOPE;
! Assume that every routine may modify the scope
scope_modified = true;
......@@ -700,7 +711,7 @@ Include "parser.h";
#IfDef DEBUG;
if(debug_flag & 1) print "(", (name) inp1, ").before()^";
#EndIf;
if(inp1 provides before) {
if(inp1.&before) {
#Ifndef OPTIONAL_MANUAL_SCOPE;
! Assume that every routine may modify the scope
scope_modified = true;
......@@ -711,7 +722,7 @@ Include "parser.h";
rfalse;
];
[ AfterRoutines _i _obj _scope_count;
[ AfterRoutines _i _obj _scope_count _max;
! react_after - Loops over the scope to find possible react_before routines
! to run in each object, if it's found stop the action by returning true
#IfnDef OPTIONAL_MANUAL_SCOPE;
......@@ -719,9 +730,11 @@ Include "parser.h";
#EndIf;
_scope_count = GetScopeCopy();
for(_i = 0: _i < _scope_count: _i++) {
if(_scope_count) {
_max = _scope_count - 1;
.next_entry;
_obj = scope_copy-->_i;
if (_obj provides react_after) {
if (_obj has reactive && _obj.&react_after ~= 0) {
#IfDef DEBUG;
if(debug_flag & 1) print "(", (name) _obj, ").react_after()^";
#EndIf;
......@@ -732,11 +745,12 @@ Include "parser.h";
if(RunRoutines(_obj, react_after))
rtrue;
}
@inc_chk _i _max ?~next_entry;
}
#IfDef DEBUG;
if(debug_flag & 1) print "(", (name) location, ").after()^";
#EndIf;
if(location provides after) {
if(location.&after) {
#Ifndef OPTIONAL_MANUAL_SCOPE;
! Assume that every routine may modify the scope
scope_modified = true;
......@@ -747,7 +761,7 @@ Include "parser.h";
#IfDef DEBUG;
if(debug_flag & 1) print "(", (name) inp1, ").after()^";
#EndIf;
if(inp1 provides after) {
if(inp1.&after) {
#Ifndef OPTIONAL_MANUAL_SCOPE;
! Assume that every routine may modify the scope
scope_modified = true;
......@@ -801,10 +815,14 @@ Include "parser.h";
_idx = p_obj - FAKE_N_OBJ;
selected_direction_index = _idx + 1;
selected_direction = _idx + N_TO_CONST;
if(p_noun_no == 1)
noun = Directions;
else
second = Directions;
if(p_noun_no == 1) {
inp1 = Directions;
noun = inp1;
}
else {
inp2 = Directions;
second = inp2;
}
}
];
......@@ -1286,7 +1304,7 @@ Object thedark "L'obscurité"
];
#Endif;
[ main _i _j _copylength _sentencelength _parsearraylength _score _again_saved _parser_oops;
[ main _i _j _copylength _sentencelength _parsearraylength _score _again_saved _parser_oops _disallow_complex_again;
#IfV3;
dict_start = HDR_DICTIONARY-->0;
......@@ -1337,7 +1355,7 @@ Object thedark "L'obscurité"
@new_line;
}
_InitFloatingObjects(); ! after initialise since location set there
_InitObjects(); ! after initialise since location set there
if(parent(player) == 0) { _i = location; location = 0; PlayerTo(_i); }
@new_line;
......@@ -1357,6 +1375,7 @@ Object thedark "L'obscurité"
#Endif;
if(parse->1 == 0) {
_ReadPlayerInput();
_disallow_complex_again = false;
#Ifdef OPTIONAL_PROVIDE_UNDO_FINAL;
if(parse-->1 == 'undo') {
PerformUndo();
......@@ -1388,26 +1407,27 @@ Object thedark "L'obscurité"
#Endif;
if(action == ##OopsCorrection) {
if(_again_saved && _parser_oops > 0) {
!print "Oops not implemented^";
_CopyInputArray(buffer2, buffer);
_CopyParseArray(parse2, parse);
_parser_oops-->0 = special_word;
_again_saved = false;
jump do_it_again;
} else {
!FRENCH
print "Désolé, il est impossible de corriger.^";
PrintMsg(MSG_PARSER_CANT_OOPS);
}
}
if(action == ##Again) {
! restore from the 'again' buffers and reparse
if(_again_saved) {
if(_disallow_complex_again) {
PrintMsg(MSG_PARSER_COMPLEX_AGAIN);
parse->1 = 0;
continue;
} else if(_again_saved) {
_CopyInputArray(buffer2, buffer);
_CopyParseArray(parse2, parse);
jump do_it_again;
} else {
!FRENCH
print "Vous ne pouvez pas répéter cela.^";
PrintMsg(MSG_PARSER_NOTHING_TO_AGAIN);
}
} else {
! store the current buffer to 'again'
......@@ -1429,17 +1449,7 @@ Object thedark "L'obscurité"
}
!FRENCH
if(_score ~= score && notify_mode == true) {
print "^[Votre score vient ";
if(_score < score) {
_j = score - _score;
print "d'augmenter";
} else {
_j = _score - score;
print "de diminuer";
}
print " de ", _j, " point";
if(_j > 1) print "s";
print ".]^";
PrintMsg(MSG_PARSER_NEW_SCORE, _score);
}
_parsearraylength = parse->1;
......@@ -1452,6 +1462,7 @@ Object thedark "L'obscurité"
parse-->_i = parse-->_j;
parse->1 = _parsearraylength - _sentencelength;
_disallow_complex_again = true; ! cannot parse "x me.g.g.g"
} else {
! the input was just one sentence
parse->1 = 0;
......
......@@ -387,3 +387,21 @@ v2.1: bug fix and new feature release
player should be able to pick up noun.
- Implicit actions only occur when the actor==player, to stop for example
"bob, give me knife" from doing unexpected things with the knife.
- Made GetScopeCopy faster.
- Removed unnecessary check for duplicates in ScopeWithin.
- Made UpdateScope avoid adding duplicates when called after a scope routine
which has already added objects.
- Optimized checking of react_before and react_after.
- Added attribute reactive which is set automatically by default but an
author can define OPTIONAL_MANUAL_REACTIVE to set it manually. Must be set
for all objects providing react_before, react_after or each_turn. Speeds
up the game.
- Added debug verb "debug reactive" which shows objects which need to get or
lose attribute reactive.
- Fixed bug in handling fake directions, which made code like <GO FAKE_N_OBJ>
break every time.
- Optimized loops in BeforeRoutine, AfterRoutines and RunEachTurn.
- Optimized so scope_copy can often be reused several times.
- Moved oops, again and score notifications messages to messages.inf
- Fixed "x me.g.g" bug (disallowing complex again commands)
- Fixed pattern filter bug that stopped some commands to reach phase 2.
......@@ -93,7 +93,8 @@ System_file;
scope-->(scope_objects++) = p_obj;
];
[ _UpdateScope p_actor p_force _start_pos _i _initial_scope_objects _current_scope_objects;
[ _UpdateScope p_actor p_force _start_pos _i _initial_scope_objects
_current_scope_objects _risk_duplicates;
if(p_actor == 0) p_actor = player;
if(scope_stage == 2) {
......@@ -110,9 +111,9 @@ System_file;
print "*** Call to UpdateScope for ", (the) p_actor, "^";;
#EndIf;
if(scope_pov == p_actor && scope_modified == false && p_force == false) return;
scope_copy_is_good = false;
scope_pov = p_actor;
_start_pos = ScopeCeiling(p_actor);
if(scope_stage == 2) {
......@@ -121,6 +122,7 @@ System_file;
_initial_scope_objects = scope_objects;
} else {
scope_objects = 0;
_risk_duplicates = 1;
}
! give entry routine a chance to override
......@@ -128,24 +130,24 @@ System_file;
! the directions are always in scope
_PutInScope(Directions);
_PutInScope(Directions, _risk_duplicates);
! if we are in a container, add it to scope
if(parent(_start_pos)) {
_PutInScope(_start_pos);
_PutInScope(_start_pos, _risk_duplicates);
}
#Ifdef OPTIONAL_NO_DARKNESS;
! Add all in player location (which may be inside an object)
_SearchScope(child(_start_pos), true, true);
_SearchScope(child(_start_pos), _risk_duplicates, true);
#Ifnot;
if(location == thedark && p_actor == player) {
! only the player's possessions are in scope
_PutInScope(player);
_SearchScope(child(player), true, true);
_PutInScope(player, _risk_duplicates);
_SearchScope(child(player), _risk_duplicates, true);
} else {
! Add all in player location (which may be inside an object)
_SearchScope(child(_start_pos), true, true);
_SearchScope(child(_start_pos), _risk_duplicates, true);
}
#Endif;
......@@ -159,13 +161,31 @@ System_file;
#EndIf;
];
#IfV5;
[GetScopeCopy p_actor _i;
#IfNot;
[GetScopeCopy p_actor _i _max;
#EndIf;
if(p_actor == 0)
p_actor = player;
_UpdateScope(p_actor);
for(_i = 0: _i < scope_objects: _i++)
scope_copy-->_i = scope-->_i;
if(scope_copy_actor ~= p_actor || scope_copy_is_good == false) {
#IfV5;
_i = scope_objects * 2;
@copy_table scope scope_copy _i;
#IfNot;
if(scope_objects) {
_max = scope_objects - 1;
.copy_next_entry;
scope_copy-->_i = scope-->_i;
@inc_chk _i _max ?~copy_next_entry;
}
#EndIf;
scope_copy_actor = p_actor;
scope_copy_is_good = true;
}
return scope_objects;
];
......@@ -236,7 +256,7 @@ Constant PlaceInScope = _PutInScope;
! scope-->(scope_objects++) = p_obj;
! ];
[ ScopeWithin p_obj _child _i;
[ ScopeWithin p_obj _child;
! DM: ScopeWithin(obj)
! Used in scope routines (only) when scope_stage is set to 2 (only).
! Places the contents of obj in scope for the token currently being
......@@ -251,11 +271,6 @@ Constant PlaceInScope = _PutInScope;
_child = child(p_obj);
if(_child == nothing) return;
! skip if already added
for(_i = 0: _i < scope_objects: _i++) {
if(scope-->_i == _child) return;
}
! add the child (will also add all siblings)
_SearchScope(_child);
];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment