938 end |
938 end |
939 else LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
939 else LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
940 lc_addammo:= 0 |
940 lc_addammo:= 0 |
941 end; |
941 end; |
942 |
942 |
|
943 function lc_getammocount(L : Plua_State) : LongInt; Cdecl; |
|
944 var gear : PGear; |
|
945 ammo : PAmmo; |
|
946 begin |
|
947 if (lua_gettop(L) = 2) then |
|
948 begin |
|
949 gear:= GearByUID(lua_tointeger(L, 1)); |
|
950 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
|
951 begin |
|
952 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
|
953 if ammo^.AmmoType = amNothing then lua_pushinteger(L, 0) |
|
954 else lua_pushinteger(L, ammo^.Count) |
|
955 end |
|
956 else lua_pushinteger(L, 0) |
|
957 end |
|
958 else LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!'); |
|
959 lc_getammocount:= 0 |
|
960 end; |
|
961 |
943 function lc_sethealth(L : Plua_State) : LongInt; Cdecl; |
962 function lc_sethealth(L : Plua_State) : LongInt; Cdecl; |
944 var gear : PGear; |
963 var gear : PGear; |
945 begin |
964 begin |
946 if lua_gettop(L) <> 2 then |
965 if lua_gettop(L) <> 2 then |
947 begin |
966 begin |
1542 exit; |
1561 exit; |
1543 |
1562 |
1544 // push game variables so they may be modified by the script |
1563 // push game variables so they may be modified by the script |
1545 ScriptSetInteger('GameFlags', GameFlags); |
1564 ScriptSetInteger('GameFlags', GameFlags); |
1546 ScriptSetString('Seed', cSeed); |
1565 ScriptSetString('Seed', cSeed); |
|
1566 ScriptSetInteger('TemplateFilter', cTemplateFilter); |
|
1567 ScriptSetInteger('MapGen', cMapGen); |
1547 ScriptSetInteger('ScreenHeight', cScreenHeight); |
1568 ScriptSetInteger('ScreenHeight', cScreenHeight); |
1548 ScriptSetInteger('ScreenWidth', cScreenWidth); |
1569 ScriptSetInteger('ScreenWidth', cScreenWidth); |
1549 ScriptSetInteger('TurnTime', cHedgehogTurnTime); |
1570 ScriptSetInteger('TurnTime', cHedgehogTurnTime); |
1550 ScriptSetInteger('CaseFreq', cCaseFactor); |
1571 ScriptSetInteger('CaseFreq', cCaseFactor); |
1551 ScriptSetInteger('HealthCaseProb', cHealthCaseProb); |
1572 ScriptSetInteger('HealthCaseProb', cHealthCaseProb); |
1566 |
1587 |
1567 ScriptCall('onGameInit'); |
1588 ScriptCall('onGameInit'); |
1568 |
1589 |
1569 // pop game variables |
1590 // pop game variables |
1570 ParseCommand('seed ' + ScriptGetString('Seed'), true); |
1591 ParseCommand('seed ' + ScriptGetString('Seed'), true); |
|
1592 ParseCommand('template_filter ' + IntToStr(ScriptGetInteger('TemplateFilter')), true); |
|
1593 ParseCommand('mapgen' + IntToStr(ScriptGetInteger('MapGen')), true); |
1571 ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), true); |
1594 ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), true); |
1572 ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true); |
1595 ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true); |
1573 ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true); |
1596 ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true); |
1574 ParseCommand('$healthprob ' + ScriptGetString('HealthCaseProb'), true); |
1597 ParseCommand('$healthprob ' + ScriptGetString('HealthCaseProb'), true); |
1575 ParseCommand('$hcaseamount ' + ScriptGetString('HealthCaseAmount'), true); |
1598 ParseCommand('$hcaseamount ' + ScriptGetString('HealthCaseAmount'), true); |
1625 begin |
1648 begin |
1626 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
1649 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
1627 ScriptSetInteger('GameTime', GameTicks); |
1650 ScriptSetInteger('GameTime', GameTicks); |
1628 ScriptSetInteger('RealTime', RealTicks); |
1651 ScriptSetInteger('RealTime', RealTicks); |
1629 ScriptSetInteger('TotalRounds', TotalRounds); |
1652 ScriptSetInteger('TotalRounds', TotalRounds); |
|
1653 ScriptSetInteger('WaterLine', cWaterLine); |
1630 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then |
1654 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then |
1631 ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID) |
1655 ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID) |
1632 else |
1656 else |
1633 ScriptSetNil('CurrentHedgehog'); |
1657 ScriptSetNil('CurrentHedgehog'); |
1634 end; |
1658 end; |
1902 lua_register(luaState, 'SetAmmo', @lc_setammo); |
1926 lua_register(luaState, 'SetAmmo', @lc_setammo); |
1903 lua_register(luaState, 'PlaySound', @lc_playsound); |
1927 lua_register(luaState, 'PlaySound', @lc_playsound); |
1904 lua_register(luaState, 'AddTeam', @lc_addteam); |
1928 lua_register(luaState, 'AddTeam', @lc_addteam); |
1905 lua_register(luaState, 'AddHog', @lc_addhog); |
1929 lua_register(luaState, 'AddHog', @lc_addhog); |
1906 lua_register(luaState, 'AddAmmo', @lc_addammo); |
1930 lua_register(luaState, 'AddAmmo', @lc_addammo); |
|
1931 lua_register(luaState, 'GetAmmoCount', @lc_getammocount); |
1907 lua_register(luaState, 'SetHealth', @lc_sethealth); |
1932 lua_register(luaState, 'SetHealth', @lc_sethealth); |
1908 lua_register(luaState, 'GetHealth', @lc_gethealth); |
1933 lua_register(luaState, 'GetHealth', @lc_gethealth); |
1909 lua_register(luaState, 'SetEffect', @lc_seteffect); |
1934 lua_register(luaState, 'SetEffect', @lc_seteffect); |
1910 lua_register(luaState, 'GetEffect', @lc_geteffect); |
1935 lua_register(luaState, 'GetEffect', @lc_geteffect); |
1911 lua_register(luaState, 'GetHogClan', @lc_gethogclan); |
1936 lua_register(luaState, 'GetHogClan', @lc_gethogclan); |