98 ScriptAmmoDelay : shortstring; |
98 ScriptAmmoDelay : shortstring; |
99 ScriptAmmoReinforcement : shortstring; |
99 ScriptAmmoReinforcement : shortstring; |
100 ScriptLoaded : boolean; |
100 ScriptLoaded : boolean; |
101 mapDims : boolean; |
101 mapDims : boolean; |
102 PointsBuffer: shortstring; |
102 PointsBuffer: shortstring; |
103 prevCursorPoint: TPoint; // why is tpoint still in sdlh... |
103 PrevCursorX, PrevCursorY: LongInt; |
104 |
104 |
105 {$IFDEF USE_LUA_SCRIPT} |
105 {$IFDEF USE_LUA_SCRIPT} |
106 procedure ScriptPrepareAmmoStore; forward; |
106 procedure ScriptPrepareAmmoStore; forward; |
107 procedure ScriptApplyAmmoStore; forward; |
107 procedure ScriptApplyAmmoStore; forward; |
108 procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward; |
108 procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward; |
3137 // not required if there is no script to run |
3137 // not required if there is no script to run |
3138 if not ScriptLoaded then |
3138 if not ScriptLoaded then |
3139 exit; |
3139 exit; |
3140 |
3140 |
3141 // push game variables so they may be modified by the script |
3141 // push game variables so they may be modified by the script |
3142 ScriptSetInteger('CursorX', CursorPoint.X); |
3142 ScriptSetInteger('CursorX', NoPointX); |
3143 ScriptSetInteger('CursorY', CursorPoint.Y); |
3143 ScriptSetInteger('CursorY', NoPointX); |
3144 ScriptSetInteger('GameFlags', GameFlags); |
3144 ScriptSetInteger('GameFlags', GameFlags); |
3145 ScriptSetInteger('WorldEdge', ord(WorldEdge)); |
3145 ScriptSetInteger('WorldEdge', ord(WorldEdge)); |
3146 ScriptSetString('Seed', cSeed); |
3146 ScriptSetString('Seed', cSeed); |
3147 ScriptSetInteger('TemplateFilter', cTemplateFilter); |
3147 ScriptSetInteger('TemplateFilter', cTemplateFilter); |
3148 ScriptSetInteger('TemplateNumber', LuaTemplateNumber); |
3148 ScriptSetInteger('TemplateNumber', LuaTemplateNumber); |
3378 ScriptLoaded:= true |
3378 ScriptLoaded:= true |
3379 end; |
3379 end; |
3380 end; |
3380 end; |
3381 |
3381 |
3382 procedure SetGlobals; |
3382 procedure SetGlobals; |
|
3383 var x, y: LongInt; |
3383 begin |
3384 begin |
3384 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
3385 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
3385 ScriptSetInteger('ReadyTimeLeft', ReadyTimeLeft); |
3386 ScriptSetInteger('ReadyTimeLeft', ReadyTimeLeft); |
3386 ScriptSetInteger('GameTime', GameTicks); |
3387 ScriptSetInteger('GameTime', GameTicks); |
3387 ScriptSetInteger('TotalRounds', TotalRounds); |
3388 ScriptSetInteger('TotalRounds', TotalRounds); |
3388 ScriptSetInteger('WaterLine', cWaterLine); |
3389 ScriptSetInteger('WaterLine', cWaterLine); |
3389 if isCursorVisible and (not bShowAmmoMenu) then |
3390 if isCursorVisible and (not bShowAmmoMenu) then |
3390 begin |
3391 begin |
3391 if (prevCursorPoint.X <> CursorPoint.X) or |
3392 x:= CursorPoint.X - WorldDx; |
3392 (prevCursorPoint.Y <> CursorPoint.Y) then |
3393 y:= cScreenHeight - CursorPoint.Y - WorldDy; |
3393 begin |
3394 if (PrevCursorX <> x) or |
3394 ScriptSetInteger('CursorX', CursorPoint.X - WorldDx); |
3395 (PrevCursorY <> y) then |
3395 ScriptSetInteger('CursorY', cScreenHeight - CursorPoint.Y- WorldDy); |
3396 begin |
3396 prevCursorPoint.X:= CursorPoint.X; |
3397 ScriptSetInteger('CursorX', x); |
3397 prevCursorPoint.Y:= CursorPoint.Y; |
3398 ScriptSetInteger('CursorY', y); |
|
3399 PrevCursorX:= x; |
|
3400 PrevCursorY:= y; |
3398 end |
3401 end |
3399 end |
3402 end |
3400 else |
3403 else |
3401 begin |
3404 begin |
3402 ScriptSetInteger('CursorX', NoPointX); |
3405 ScriptSetInteger('CursorX', NoPointX); |
3403 ScriptSetInteger('CursorY', NoPointX); |
3406 ScriptSetInteger('CursorY', NoPointX); |
3404 prevCursorPoint.X:= NoPointX; |
3407 PrevCursorX:= NoPointX; |
3405 prevCursorPoint.Y:= NoPointX |
3408 PrevCursorY:= NoPointX |
3406 end; |
3409 end; |
3407 |
3410 |
3408 if not mapDims then |
3411 if not mapDims then |
3409 begin |
3412 begin |
3410 mapDims:= true; |
3413 mapDims:= true; |