Init commit

This commit is contained in:
strongleong 2023-02-07 04:46:47 +11:00
commit 6319d05b8f
14 changed files with 9433 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.pyc
bins/
out/

27
.vimrc Normal file
View file

@ -0,0 +1,27 @@
" %E%.%# %f:%l
" %CLine |
" %C %#%*[0123456789] %#| %.%#
" %-C %#| %#~%#
" %C %#| %m
" %Z
"
" %ETraceback %.%#:
" %C File "%f", line %l,%.%#
" %C %.%#
" %Z%m
" set makeprg=pwsh\ -c\ .\\Police2Gear\\build.ps1
set makeprg=pwsh\ -c\ .\\build.ps1
set efm=%-G,
\%trror:\ %m,
\%E%.%#\ %f:%l,
\%CLine\ \|,
\%C\ %#%*[0123456789]\ %#\|\ %.%#,
\%-C\ %#\|\ %#~%#,
\%C\ %#\|\ %m,
\%Z,
\%ETraceback\ %.%#:,
\%C\ \ File\ \"%f\"\\,\ line\ %l\\,\ %.%#,
\%C\ \ \ \ %.%#,
\%Z%m

3
Loader/README.md Normal file
View file

@ -0,0 +1,3 @@
# Loader
This is just `init.py` with my custom files preloaded

618
Loader/scripts/init.py Normal file
View file

@ -0,0 +1,618 @@
##########################################################
# Initialization engine
##########################################################
# Cam = Scrap.GetEntity(Scrap.GetCam(0))
# Scrap.GetEntity(Scrap.GetCam(0)).CamDist = 0
# Scrap.GetEntity(Scrap.GetCam(0)).FreeCam = 1
# Scrap.GetEntity("net256").Descriptor
# Scrap.GetEntity(Scrap.GetEntity("Player1").Target).Life = 0
# Scrap.GetEntity("Player1").EMICounter = 1.0
# Scrap.GetEntity("Player1").Upgrd01 = 3;Scrap.GetEntity("Player1").UAmmo01 = 200
# import Vehicles;Vehicles.ReSpawnShip("Player1")
# Scrap.GetEntity("Player1").FireRemainTime = 10.0;Scrap.GetEntity("Player1").FireDelayTime = 0.2
# import Net;Net.Spectate(0,1)
# Scrap.GetEntity("Player1").ActCtrl = "Mosquito"
import Scrap
def log(msg):
Scrap.Print("[STRNG][INIT] " + msg + "\n")
log('Init started')
PlaySpacelords = not Scrap.IsApp(436180) # 1 to activate the cross promotion
##################################
## All the built in functions
##################################
import SInput,SNet,SWeap,SScorer,SSound,SAct,sys,SAI,SFX
Scrap.CreateSaveVar("CreateBertos", "0")
Scrap.CreateSaveVar("MercsHelpDtritus", "0")
Scrap.CreateSaveVar("RobotsControlledByBoss", "0")
Scrap.CreateSaveVar("Player.InfiniteLives", "1")
# WARNING : Never import any pyhton source library at the start up!
#
SUPERDEALSMAPS = ["TUCZONE","QF","OM","FZ","CA"]
OUTMAPS = ["TUCZONE","AB","COMMERCIAL","DOWNTOWN","GDB","OUTSKIRTS","SCRAPYARD"]+SUPERDEALSMAPS
INMAPS = ["NANO","ABINDOOR","BANK","GAMBLINDEN","ORBIT","POLICE","PRESS","TEMPLE","TOWNHALL"]
ExtraExecs ={
"JUNKYARD":(
(Scrap.PreloadLibrary,('RustySound', 'Sound/RustySound.pyc' )),
(Scrap.PreloadLibrary,('SputnikJunkyardSound','Sound/SputnikJunkyardSound.pyc' )),
(Scrap.PreloadLibrary,('MaintenanceSound', 'Sound/MaintenanceSound.pyc' )),
(Scrap.PreloadLibrary,('Rusty', 'Chars/Rusty.pyc' )),
(Scrap.PreloadLibrary,('SputnikJunkyard', 'Chars/SputnikJunkyard.pyc' )),
(Scrap.PreloadLibrary,('Maintenance', 'Chars/Maintenance.pyc' )),
),
"GAMBLINDEN":(
(Scrap.PreloadLibrary,('MercenarySound', 'Sound/MercenarySound.pyc' )),
(Scrap.PreloadLibrary,('CrazyGamblerSound', 'Sound/CrazyGamblerSound.pyc' )),
(Scrap.PreloadLibrary,('MercenaryA', 'Chars/MercenaryA.pyc' )),
(Scrap.PreloadLibrary,('MercenaryB', 'Chars/MercenaryB.pyc' )),
(Scrap.PreloadLibrary,('MercenaryC', 'Chars/MercenaryC.pyc' )),
(Scrap.PreloadLibrary,('MercenaryL', 'Chars/MercenaryL.pyc' )),
(Scrap.PreloadLibrary,('CrazyGambler', 'Chars/CrazyGambler.pyc' )),
),
"ABINDOOR":(
(Scrap.PreloadLibrary,('CrazyGamblerSound', 'Sound/CrazyGamblerSound.pyc' )),
(Scrap.PreloadLibrary,('CrazyGambler', 'Chars/CrazyGambler.pyc' )),
),
"PRESS":(
(Scrap.PreloadLibrary,('SebastianSound', 'Sound/SebastianSound.pyc' )),
(Scrap.PreloadLibrary,('BossSound', 'Sound/BossSound.pyc' )),
(Scrap.PreloadLibrary,('Sebastian', 'Chars/Sebastian.pyc' )),
(Scrap.PreloadLibrary,('Boss', 'Chars/Boss.pyc' )),
),
}
OffLineGame = Scrap.GetNetFlags()==(0,0,0)
MultiPlayer = not OffLineGame or Scrap.Get("SplitScreen") != 0
############################################################################################################
#################################### Preload all the built in libraries ####################################
############################################################################################################
# todos los paths
sys.path.append('Scripts/Scorer')
sys.path.append('Scripts/ShipEdit')
sys.path.append('Scripts/Python')
sys.path.append('Scripts/Weapons')
sys.path.append('Scripts/Vehicles')
sys.path.append('Scripts/Net')
sys.path.append('Scripts/FX')
sys.path.append('Scripts/Sound')
sys.path.append('Scripts/Chars')
sys.path.append('Scripts/Missions')
sys.path.append('Scripts/SuperDeals')
sys.path.append('Scripts/Split')
###### Librerias standard de python ######
Scrap.PreloadLibrary('string','Python/string.pyc')
# determinar el ambito de los mapas...
import string
UpperMap = string.upper(Scrap.GetLevelPath()[7:])
SuperDealModule = None
sDealType = Scrap.GetSaveVar("SuperDealType")
HasSuperDeal = OffLineGame and sDealType and sDealType != "" and (UpperMap in SUPERDEALSMAPS)
OutMapSkip = OffLineGame and (UpperMap in OUTMAPS)
InMapSkip = OffLineGame and (UpperMap in INMAPS)
#Scrap.PreloadLibrary('QuickConsole','QuickConsole.pyc') # QuickConsole no es una libreria para el sistema
###### Librerias basicas del sistema raiz ######
Scrap.PreloadLibrary('Items','Items.pyc')
Scrap.PreloadLibrary('SaveGame','SaveGame.pyc')
###### Sistema de menues y scorer ######
log('Preloading ModsMenu')
Scrap.PreloadLibrary('MyMenu','Scorer/MyMenu.pyc')
log('ModsMenu preload injected')
if (Scrap.Get("IsXbox") == 1):
Scrap.PreloadLibrary('XBMenu','Scorer/XBMenu.pyc')
else:
Scrap.PreloadLibrary('PCMenu','Scorer/PCMenu.pyc')
Scrap.PreloadLibrary('Menu','Scorer/Menu.pyc')
Scrap.PreloadLibrary('Scorer','Scorer/Scorer.pyc')
Scrap.PreloadLibrary('CharScorer','Scorer/CharScorer.pyc')
###### Librerias de red ######
Scrap.PreloadLibrary('Net', 'Net/Net.pyc')
###### Efectos especiales ######
Scrap.PreloadLibrary('Fx', 'FX/Fx.pyc' )
###### Sistema de sonidos ######
Scrap.PreloadLibrary('Sound', 'Sound/Sound.pyc' )
Scrap.PreloadLibrary('DoorSound', 'Sound/DoorSound.pyc' )
###### Sistema de personajes ######
Scrap.PreloadLibrary('Chars', 'Chars/Chars.pyc' )
Scrap.PreloadLibrary('MakeChar', 'Chars/MakeChar.pyc')
Scrap.PreloadLibrary('Speech', 'Chars/Speech.pyc' )
Scrap.PreloadLibrary('CharAct', 'Chars/CharAct.pyc' )
###### Librerias ######
Scrap.PreloadLibrary('Teleport', 'Missions/Teleport.pyc' )
Scrap.PreloadLibrary('Elevator', 'Missions/Elevator.pyc' )
Scrap.PreloadLibrary('RaceMaker', 'Missions/RaceMaker.pyc' )
Scrap.PreloadLibrary('Doors', 'Missions/Doors.pyc' )
Scrap.PreloadLibrary('Alarm', 'Missions/Alarm.pyc' )
Scrap.PreloadLibrary('MisItems', 'Missions/MisItems.pyc' )
Scrap.PreloadLibrary('Traffic', 'Missions/Traffic.pyc' )
Scrap.PreloadLibrary('Scene', 'Missions/Scene.pyc' )
Scrap.PreloadLibrary('Challenge', 'Missions/Challenge.pyc' )
Scrap.PreloadLibrary('MissionsFuncs', 'Missions/MissionsFuncs.pyc' )
Scrap.PreloadLibrary('Metro', 'Missions/Metro.pyc' )
def LoadCharLib(filename):
Scrap.PreloadLibrary(filename, 'Chars/'+filename+'.pyc' )
filename = filename+"Sound"
Scrap.PreloadLibrary(filename, 'Sound/'+filename+'.pyc')
if not InMapSkip: # no es interiores
###### Armas de naves preparadas para red ######
Scrap.PreloadLibrary('Weapons', 'Weapons/Weapons.pyc' )
Scrap.PreloadLibrary('Vulcan', 'Weapons/Vulcan.pyc' )
Scrap.PreloadLibrary('Swarm', 'Weapons/Swarm.pyc' )
Scrap.PreloadLibrary('Tesla', 'Weapons/Tesla.pyc' )
Scrap.PreloadLibrary('Cloud', 'Weapons/Cloud.pyc' )
Scrap.PreloadLibrary('Sonic', 'Weapons/Sonic.pyc' )
Scrap.PreloadLibrary('EMI', 'Weapons/EMI.pyc' )
Scrap.PreloadLibrary('Devastator','Weapons/Devastator.pyc')
Scrap.PreloadLibrary('ATPC', 'Weapons/ATPC.pyc' )
Scrap.PreloadLibrary('Inferno', 'Weapons/Inferno.pyc' )
Scrap.PreloadLibrary('Laser', 'Weapons/Laser.pyc' )
###### Naves y afines ######
Scrap.PreloadLibrary('Vehicles', 'Vehicles/Vehicles.pyc' )
Scrap.PreloadLibrary('ShipMaker', 'Vehicles/ShipMaker.pyc' )
Scrap.PreloadLibrary('OutMap', 'Vehicles/OutMap.pyc' )
Scrap.PreloadLibrary('VehiclesNPC', 'Vehicles/VehiclesNPC.pyc' )
Scrap.PreloadLibrary('Parking', 'Vehicles/Parking.pyc' )
Scrap.PreloadLibrary('Accelerator', 'Vehicles/Accelerator.pyc' )
####### scorer solo de exteriores ######
Scrap.PreloadLibrary('RacerScorer','Scorer/RacerScorer.pyc')
####### Sputnick y sus naves #######
LoadCharLib('Sputnik')
Scrap.PreloadLibrary('SputnikInterface', 'ShipEdit/SputnikInterface.pyc' )
####### sonidos de exteriores #######
Scrap.PreloadLibrary('OutSound', 'Sound/OutSound.pyc' )
###### mas misiones de exteriores ######
Scrap.PreloadLibrary('OutPolice', 'Missions/OutPolice.pyc' )
Scrap.PreloadLibrary('PhoneCab', 'Missions/PhoneCab.pyc' )
###### Sistema de edicion de naves ######
Scrap.PreloadLibrary('ShipEdit', 'ShipEdit/ShipEdit.pyc' )
Scrap.PreloadLibrary('HangarTab', 'ShipEdit/HangarTab.pyc' )
if not OutMapSkip: # tampoco interiores (mapas de edicion de naves)
Scrap.PreloadLibrary('EnginesTab','ShipEdit/EnginesTab.pyc')
Scrap.PreloadLibrary('WeaponsTab','ShipEdit/WeaponsTab.pyc')
Scrap.PreloadLibrary('HullTab', 'ShipEdit/HullTab.pyc' )
if not OutMapSkip:
for fn in ('Nurse','Police','Desktop','Gear','Sentinel','Berto',
'BankDirector','Mayor','GateKeeper','Betty','Dtritus',
'Bishop','Functionary','Humphrey','PoliceBoss',
'Messenger','Human','BankMaster'):
LoadCharLib(fn)
# logica varias de interiores
Scrap.PreloadLibrary('CrazyWing', 'Missions/CrazyWing.pyc' )
Scrap.PreloadLibrary('Bureaucracy', 'Chars/Bureaucracy.pyc' )
Scrap.PreloadLibrary('CharsNPC', 'Chars/CharsNPC.pyc' )
Scrap.PreloadLibrary('InMap', 'Chars/InMap.pyc' )
Scrap.PreloadLibrary('InTraffic', 'Vehicles/InTraffic.pyc' )
Scrap.PreloadLibrary('DTritusDesktop','Missions/DTritusDesktop.pyc')
# Sistema de misiones para single player
Scrap.PreloadLibrary('InPolice', 'Missions/InPolice.pyc' )
Scrap.PreloadLibrary('CharConversor', 'Missions/CharConversor.pyc' )
Scrap.PreloadLibrary('NewsPanel', 'Missions/NewsPanel.pyc' )
else: # debo cargar si es un mapa exterior solo mi personaje...
LoadCharLib(Scrap.GetSaveVar("Char"))
if Scrap.Get("SplitScreen") != 0 or (Scrap.Get("isXbox") and UpperMap in ("MENU","SHIPEDIT")):
Scrap.PreloadLibrary('Split','Split/Split.pyc')
SplitModeGameMod = Scrap.Get("ServerType")
Scrap.PreloadLibrary('S'+SplitModeGameMod,'Split/S'+SplitModeGameMod+'.pyc')
import Split
Split.ModLib = __import__('S'+SplitModeGameMod)
if not OffLineGame:
Scrap.PreloadLibrary('Chat','Scorer/Chat.pyc')
Scrap.PreloadLibrary('Ffa', 'Net/Ffa.pyc')
# cargar la libreria del tipo de juego...
import Ffa
GameLibName = "N"+Scrap.Get("ServerType")
if not Scrap.FileExist('Scripts/Net/'+GameLibName+'.pyc') and not Scrap.FileExist('Scripts/Net/'+GameLibName+'.py'):
GameLibName = "NDeathMatch"
Scrap.PreloadLibrary(GameLibName, 'Net/'+GameLibName+'.pyc')
Ffa.ModLib = __import__(GameLibName)
if ExtraExecs.has_key(UpperMap):
for func in ExtraExecs[UpperMap]:
apply(apply,func)
isDemo = Scrap.Get("isDemo")
Path = "" # el path del mapa actual
Outdoor = 1 # 1 si el mapa es exterior 0 si es interior. En red debe ser 1
inMainMenu = 0 # 1 si el mapa no es mas que una miserable demo si graficos ni nada
isShipEdit = 0 # 1 si el mapa es el edicion de naves. inMainMenu = 0 Outdoor = 1 para que sea valido
isJunkYard = 0 # 1 en el caso particular del mapa junkyard
OutArea = "DownTown" # este es el mapa exterior en el que se encuentra (si esta en un interior) no vale para exteriores ni mapa del chatarrero.
isScrapYard = 0
XboxSavingMsgTime = 3.5
if (HasSuperDeal):
Scrap.PreloadLibrary(sDealType, 'SuperDeals/' + sDealType + '.pyc' )
SuperDealModule = __import__(sDealType)
######## Maplibs functions ########
MapLibs = [] # esta es la lista de las librerias propias del mapa. Se especifican para su inicializacion
# agrega una libreria a la lista de librerias del mapa
def AddMLib(library):
global MapLibs
MapLibs.append(library)
def MLibInitStatus(LevelPath):
global MapLibs
for lib in MapLibs:
lib.InitStatus(LevelPath)
def MLibInit(LevelPath):
global MapLibs
for lib in MapLibs:
lib.Init(LevelPath)
def isMission():
import string
return string.upper(Scrap.GetSaveVar("Mission.Map")) == string.upper(Scrap.GetLevelPath()[7:])
def PreloadMlibs(LevelPath):
import Map
if isMission():
Map.Libraries.append(Scrap.GetSaveVar("Mission.Library"))
if "Libraries" in dir(Map):
for LibName in Map.Libraries:
Scrap.PreloadLibrary(LibName,LibName+'.pyc')
AddMLib(__import__(LibName))
Arrows = "Models/Misc/Action/Action","Models/Misc/MMission/MMission","Models/Misc/SMission/SMission","Models/Misc/MMission/BMMission","Models/Misc/SMission/BSMission"
Scrap.Set("ArrowUseFile", Arrows[0])
Scrap.Set("ArrowMissionFile", Arrows[1])
Scrap.Set("ArrowTargetFile", Arrows[2])
def SetArrowSize():
global Arrows
for varnam in Arrows:
Nam = varnam
Scrap.Preload3DObject(Nam+".M3D",1,1,1)
Scrap.PreloadAnm(Nam+".M3D",Nam+".anim.M3D")
####################################
## Initialization routines
####################################
def Init(LevelPath):
global Path
global Outdoor
global inMainMenu
global isShipEdit
# graba el path
Path = LevelPath
# load default libraries
import sys
sys.path.append(LevelPath+"/Scripts")
Scrap.OpenPack(LevelPath+"/Scripts")
Scrap.PreloadLibrary('Map','Map.pyc')
Scrap.PreloadLibrary('MapSnd','MapSnd.pyc')
PreloadMlibs(LevelPath)
Scrap.ClosePack()
if Scrap.Get("IsXbox") and not Scrap.Get("ShowCredits") and UpperMap in ("SHIPEDIT","MENU"):
Scrap.PreloadLibrary('XboxMenu', 'Scripts/Scorer/XboxMenu.pyc')
AddMLib(__import__('XboxMenu'))
import Map
import MapSnd
# Load map Status
Map.InitStatus(LevelPath)
MLibInitStatus(LevelPath)
###################################################################
# Para arreglar el que se vea a la nave del jefe de policia dando #
# rulos por ahн despuйs de muerto y no tener que hacer cambios en #
# todos los scripts de exteriores. #
###################################################################
ga = Scrap.GetSaveVar("GameAct")
if (ga != "Prologue" and ga != "1stMurder"):
import string
cad = Scrap.GetSaveVar("Traffic.AcShips")
if (cad and string.find(cad, "SPoliBoss1") != -1):
import Traffic
cad = string.replace(cad, "SPoliBoss1", "SPoli6", 1)
Scrap.SetSaveVar("Traffic.AcShips", cad)
Traffic.AcShips = eval(cad)
#######################################################
if (SuperDealModule):
SuperDealModule.InitStatus(LevelPath)
# modifica el tamaсo de las flechas de mision
if not inMainMenu and not isShipEdit:
SetArrowSize()
#inicializaciуn AI
SAI.IniAI(LevelPath, Outdoor)
# initialize the language
#Scrap.SetLanguage("English")
# Initialize menu
Scrap.Set("EscapeEvent","Menu.Init")
import Menu; Menu.Initialize()
# Assign Mission Info callback func
if Scrap.GetNetFlags()==(0,0,0):
Scrap.Set("MainMissionEvent", "MissionsFuncs.ShowMissionInfo")
else:
Scrap.Set("MainMissionEvent", "Ffa.ShowHelp")
if not OffLineGame:
# Initialize chat system
import Chat;Chat.SetChatProc();
# Initialize the sound system
import Sound;Sound.Init()
# elementos decorativos
Scrap.CreateElements()
if not inMainMenu:
if not Outdoor:
import Bureaucracy; Bureaucracy.Init()
if UpperMap in SUPERDEALSMAPS or MultiPlayer:
Scrap.Set("isActionMusic",1)
# Initialize Character Controller (en exteriores al menos se carga un set para el single player, nada para el multi)
if not isShipEdit and not MultiPlayer:
import Chars; Chars.Init()
if (not isJunkYard):
if (Outdoor):
import PhoneCab
PhoneCab.CreatePhoneCabClass()
PhoneCab.CreateAudioComClass()
#else:
# Scrap.SetMoney(1000000)
if Outdoor or isJunkYard: # lo que son interiores no cargan nada de esto (exepto Junkyard)
# Initialize Vehicle Controller
import Vehicles;Vehicles.Init()
# Initialize Weapons Controller
import Weapons;Weapons.Init()
# Initialize Special FX Controller (generico para exteriores e interiores)
import Fx;Fx.Init()
if not isShipEdit:
# sistema de alarma
import Alarm;Alarm.Init()
# Items propios de las misiones
import MisItems;MisItems.Init()
# puertas y ventanas
import Doors;Doors.Init()
if not isShipEdit:
# Set de los mapas ya sean exteriores o interiores.
if Outdoor:
import OutMap;OutMap.Init(LevelPath)
else:
import InMap;InMap.Init(LevelPath)
if not MultiPlayer:
import SaveGame
SaveGame.InitVars()
import MissionsFuncs;MissionsFuncs.Init()
###Scrap.Set( "VideoGammaRGB", 1.0 )
if (Outdoor and Scrap.GetSaveVar("CreateBertos") == "1" and UpperMap != "GDB" and not HasSuperDeal):
import MissionsFuncs, Parking
MissionsFuncs.CreateBertos()
Parking.SwitchVehicleMissionCallbackAux = MissionsFuncs.ReassignBertosPlayerTarget
Parking.SwitchCharMissionCallbackAux = MissionsFuncs.ReassignBertosPlayerTarget
if (Scrap.GetSaveVar("RobotsControlledByBoss") == "1"):
if (Scrap.GetSaveVar("MercsHelpDtritus") == "1"):
Scrap.SetSaveVar("MercFriends.MercenaryA_Smartie", "1")
Scrap.SetSaveVar("MercFriends.MercenaryC_Brutus", "1")
Scrap.SetSaveVar("MercFriends.MercenaryB_Dumber", "1")
if UpperMap in eval(Scrap.GetSaveVar("ComSatsMissionsMapsFinished")):
Scrap.Set("AlarmFallDelta", -0.05)
Scrap.SetAlarm(0)
else:
Scrap.SetAlarm(1)
Scrap.Set("AlarmFallDelta",0)
Scrap.Set("OnCrazyDealFinished", "MissionsFuncs.OnCrazyDealFinishedMessage")
Scrap.Set("OnCrazyDealTarget", "MissionsFuncs.OnCrazyDealTarget")
# initialize the map
Map.Init(LevelPath)
MapSnd.Init(LevelPath)
MLibInit(LevelPath)
if (SuperDealModule):
SuperDealModule.Init(LevelPath)
Scrap.AddScheduledFunc(Scrap.GetTime() + 0.5, SetMapLabelText, ())
if (isDemo and Scrap.GetSaveVar("Player.NumLives") == "-1"):
Scrap.SetSaveVar("Player.NumLives", "0")
Scrap.Set("R_SceneBlurValue",0)
if OffLineGame and not inMainMenu and not isShipEdit:
Scrap.CreateSaveVar("GameSkill", "1")
Scrap.Set("GameSkill",int(Scrap.GetSaveVar("GameSkill")))
print "Actual Level at : ",LevelPath
def SetMapLabelText():
import Scorer
vis = SScorer.Get(0, Scorer.MissionScorerName, "Visible")
if (vis and vis == 1):
status = SScorer.Get(0, Scorer.MissionScorerName, "Status0")
if (status != 1 or (status == 1 and Scrap.GetSaveVar("Mission.Map") == Scrap.GetLevelPath()[7:])):
SScorer.SetLabelText(Scrap.GetLangStr("Station_" + Scrap.GetLevelPath()[7:]), Scrap.GetTime() + 10)
# Scrap.CreateSaveVar("Mission01","Searching")
# Scrap.CreateSaveVar("Mission01.Objetive","BadGuy")
# Scrap.GetSaveVar("Mission01")
# Scrap.DelSaveVars("Mission01.")
# Scrap.SetSaveVar("Mission01","Eliminate")
# Scrap.SaveGameVars("Save/Save01.sav")
# Scrap.LoadGameVars("Save/Save01.sav")
####################################
## Closing routines
####################################
PROGRESSBAR_PC = {
"MENU":200,
"ORBIT":1070,
"SCRAPYARD":1693,
"BANK":1641,
"JUNKYARD":1434,
"SHIPEDIT":1265,
"DOWNTOWN":1745,
"OUTSKIRTS":1775,
"GAMBLINDEN":1252,
"COMMERCIAL":1790,
"FAKE":1462,
"PRESS":1691,
"POLICE":1764,
"TEMPLE":1382,
"TOWNHALL":1742,
"AB":1366,
"ABINDOOR":868,
"QF":1474,
"GDB":1517,
"FZ":1488,
"OM":1537,
"CA":1487,
"MCA":1553,
"MCB":1553,
"MDA":1553,
"MDB":1553,
"MOA":1553,
"MOB":1553,
"MSA":1553,
"MSB":1553,
}
PROGRESSBAR_XBOX = {
"MENU":200,
"ORBIT":845,
"SCRAPYARD":1189,
"BANK":1327,
"JUNKYARD":990,
"SHIPEDIT":589,
"DOWNTOWN":1208,
"OUTSKIRTS":1182,
"GAMBLINDEN":995,
"COMMERCIAL":1214,
"FAKE":1208,
"PRESS":1448,
"POLICE":1533,
"TEMPLE":1162,
"TOWNHALL":1539,
"AB":844,
"ABINDOOR":690,
"QF":968,
"GDB":964,
"FZ":975,
"OM":1014,
"CA":953,
"MCA":1042,
"MCB":1016,
"MDA":1046,
"MDB":1048,
"MOA":945,
"MOB":985,
"MSA":987,
"MSB":857,
}
def Close():
# Guarda el nъmero de ficheros a leer en el siguiente nivel
UpperMap = string.upper(Scrap.GetNewLevelPath()[7:])
print "Next level: %s" % UpperMap
PROGRESSBAR = ""
if Scrap.Get("IsXbox") == 1 :
PROGRESSBAR = PROGRESSBAR_XBOX
else :
PROGRESSBAR = PROGRESSBAR_PC
if PROGRESSBAR.has_key(UpperMap):
Scrap.Set("ProgressBar", PROGRESSBAR[UpperMap])
else:
Scrap.ConsoleError("ERROR: '%s' progress bar info not found \n" % UpperMap)
Scrap.Set("ProgressBar", Scrap.Def("ProgressBar"))

10
Logger/README.md Normal file
View file

@ -0,0 +1,10 @@
# Logger
Logger for logging stuff.
```pyhton
import Logger
Logger.info("A")
Logger.error("OH NO!")
```

View file

@ -0,0 +1,29 @@
import Scrap
class Logger:
def __init__(self, name):
self.level=""
self.name=name
def __repr__(self):
return "<Logger>"
def __call__(self, *args):
# frame = sys.modules[__name__].last_frame
# frame_info = (frame.f_code.co_name,frame.f_code.co_name)
# Scrap.Print(repr(frame_info)+"\n")
args=list(args)
for i in range(len(args)):
args[i]=str(args[i])
args = ["["+str(self.name)+"|"+string.upper(self.level)+"]"]+args
msg = string.join(args," ")
Scrap.Print(msg+"\n")
def __getattr__(self, level):
self.level=level
return self

4
Police2Gear/README.md Normal file
View file

@ -0,0 +1,4 @@
# Police2Gear
Mod that replaces police default money-bagging action with transforming to
geared police

View file

@ -0,0 +1,517 @@
import Scrap
import SInput
import SNet
import SWeap
import SScorer
import SSound
import SVec
import SAct
import sys
def log(msg):
Scrap.Print("[STRNG][Police] " + str(msg) + "\n")
# WARNING : Never import any pyhton source library at the start up!
FXPoliceStealFile = "Models/GFX/Police/PoliceSteal.M3D"
FXPoliceGearConversionFile = "Models/GFX/Police/Conversion.M3D"
def LoadSirenActs():
# inicio de la sirena
SAct.CreateAction("SirenInit")
SAct.SetAct("isLoop",0)
SAct.SetAct("Chanel",1)
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_SirenInit.M3D")
SAct.SetAct("AddEventAtTime",SAct.GetAct("AnmTotalTime"))
SAct.SetAct("EventName","Siren")
SAct.SetAct("EventFunc","!AnmSetAction")
SAct.SetAct("AddEventAtTime",SAct.GetAct("TimeOfFrame"+"6"))
SAct.SetAct("EventName","FXPoliceAlarmInit")
SAct.SetAct("EventFunc","!FXPoliceAlarmInit")
# loop de la sirena
SAct.CreateAction("Siren")
SAct.SetAct("isLoop",1)
SAct.SetAct("Chanel",1)
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_Siren.M3D")
SAct.SetAct("MaxSpeed",1.3)
SAct.SetAct("MinSpeed",1.4)
# final de la sirena
SAct.CreateAction("SirenEnd")
SAct.SetAct("isLoop",0)
SAct.SetAct("Chanel",1)
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_SirenEnd.M3D")
SAct.SetAct("AddEventAtTime",SAct.GetAct("TimeOfFrame"+"65"))
SAct.SetAct("EventName","FXPoliceAlarmEnd")
SAct.SetAct("EventFunc","!FXPoliceAlarmEnd")
def Init():
import MakeChar, Init, string
MakeChar.InitChar ("Police")
# ajustes varios de velocidad
MakeChar.MaxSpeed = 1.2
MakeChar.MinSpeed = 0.6
MakeChar.AddRelaxActions("Police",0)
SAct.GetAction("Relax0")
SAct.SetAct("anmConeView",1)
MakeChar.AddWalkActions ("Police",360,1)
MakeChar.AddFallAction ("Police",45,1,0)
MakeChar.AddDazeAction ("Police")
MakeChar.AddTalkAction ("Police",nExtraActions=3)
MakeChar.AddDiscover ("Police")
MakeChar.AddInitWalkActions("Police",360,0,1,["StrLeftInit","StrRightInit"])
MakeChar.AddFlashedAction("Police")
MakeChar.AddCrazyAction ("Police")
SAct.GetCls("Police")
SAct.SetCls("WRadius",69) # Radio de colision con el mundo
SAct.SetCls("VRadius",60) # Radio de colision con el mundo
SAct.SetCls("SRadius",20) # Radio de la capsula de soporte
SAct.SetCls("MinFallDist",20) # tamaño maximo que acepta como escalon para las caidas
#### Lista de modificadores de nodos del policia ####
SAct.SetCls("Node0Name","Bip PoliceNoArmor Head") # Cabeza
SAct.SetCls("Node1Name","Bip PoliceNoArmor Spine1") # Tronco
# Relax
MakeChar.SetNodeRotation(0,0, 25, 50) # Cabeza
MakeChar.SetNodeRotation(0,1, 25, 50) # Tronco
#### Cuando le dan en la cabeza, la sirena se hunde
SAct.GetAction("DazedInit")
SAct.SetAct("AddEventAtTime",SAct.GetAct("AnmTotalTime"))
SAct.SetAct("EventName","AbortSiren")
SAct.SetAct("EventFunc","Police.AbortSiren")
#### Acciones Extra ####
# animavion de andandara
MakeChar.CreateRelaxAction("Police",90,"AlertCheck","Relax0")
SAct.GetAction("AlertCheck")
SAct.SetAct("anmConeView",1)
for ActName in (("",0),("NPC",360)):
# try get money
SAct.CreateAction("ActionInit"+ActName[0])
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_ActionInit.M3D")
SAct.SetAct("isLoop",0)
SAct.SetAct("RotSpeed",ActName[1])
SAct.SetAct("UseDisp",0)
SAct.SetAct("PriorityLevel",100)
# evento de "Te succiono el dinero"
SAct.SetAct("AddEventAtTime",0.3)
SAct.SetAct("EventName","PoliceRestoreFreeTurn")
SAct.SetAct("EventFunc","!PoliceRestoreFreeTurn")
SAct.SetAct("EventDiscardable",0)
# trying to get money
SAct.CreateAction("Action"+ActName[0])
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_Action.M3D")
SAct.SetAct("isLoop",1)
SAct.SetAct("RotSpeed",ActName[1])
SAct.SetAct("UseDisp",0)
SAct.SetAct("PriorityLevel",101)
# evento de "Te succiono el dinero"
SAct.SetAct("AddEventAtTime",SAct.GetAct("AnmTotalTime")*1.5)
SAct.SetAct("EventName","ShowMeTheMoney")
SAct.SetAct("EventFunc","!PoliceEndActionMoney")
# Bad luck getting money
SAct.CreateAction("ActionBad")
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_ActionBad.M3D")
SAct.SetAct("isLoop",0)
SAct.SetAct("RotSpeed",0)
SAct.SetAct("UseDisp",0)
SAct.SetAct("PriorityLevel",101)
# Bad luck getting money
SAct.CreateAction("ActionOK")
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_ActionOK.M3D")
SAct.SetAct("isLoop",0)
SAct.SetAct("RotSpeed",0)
SAct.SetAct("UseDisp",0)
SAct.SetAct("PriorityLevel",101)
# We laugh, and cry too
SAct.CreateAction("Laugh")
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_Laugh.M3D")
SAct.SetAct("isLoop",0)
SAct.SetAct("RotSpeed",360)
SAct.SetAct("UseDisp",0)
SAct.SetAct("PriorityLevel",102)
SAct.SetAct("NodeModifier",-1)
SAct.SetAct("AngleModifierSpeed",1.0)
SAct.SetAct("AutoFaceSpeed", 10)
SAct.SetAct("AutoFaceOffsetH", 0)
SAct.SetAct("AutoFaceOffsetV", 0)
import Init
if not Init.Outdoor:
# Police Fusion
SAct.CreateAction("Fusion")
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_Fusion.M3D")
SAct.SetAct("isLoop",0)
SAct.SetAct("PriorityLevel",200)
# evento de conversión de Policia en Gear
SAct.SetAct("AddEventAtTime",0)
SAct.SetAct("EventName","FusionInit")
SAct.SetAct("EventFunc","!FXPoliceGearConversion")
SAct.SetAct("EventDiscardable",0)
# evento de cambiazo efectivo y brutal!
SAct.SetAct("AddEventAtTime",SAct.GetAct("AnmTotalTime"))
SAct.SetAct("EventName","FusionInit")
# SAct.SetAct("EventFunc","Police.GotGear")
SAct.SetAct("EventFunc","!Police2GearEnd")
SAct.SetAct("EventDiscardable",0)
SAct.CreateAction("ActionFusion")
SAct.SetAct("AnmFilePath","Models/Chars/Police/Anm/Police_Fusion.M3D")
SAct.SetAct("isLoop",0)
SAct.SetAct("PriorityLevel",200)
# evento de conversión de Policia en Gear
SAct.SetAct("AddEventAtTime",0)
SAct.SetAct("EventName","ActionFusionInit")
SAct.SetAct("EventFunc","!FXPoliceGearConversion")
SAct.SetAct("EventDiscardable",0)
# evento de cambiazo efectivo y brutal!
SAct.SetAct("AddEventAtTime",SAct.GetAct("AnmTotalTime"))
SAct.SetAct("EventName","ActionFusionInit")
# SAct.SetAct("EventFunc","Police.GotGear")
# SAct.SetAct("EventFunc","!Police2GearEnd")
SAct.SetAct("EventDiscardable",0)
if string.upper(Init.Path) == 'LEVELS/GAMBLINDEN':
#MakeChar.CreateRelaxAction("Police",180,"Dance0", "Dance0" )
MakeChar.CreateRelaxAction("Police",180,"Dance", "Dance" )
SAct.SetAct("isLoop",1)
LoadSirenActs()
SAct.SetCls("OnCreate","Police.OnCreate")
SAct.SetCls("OnFreeResources","Police.OnFreeResources")
#### Police actions ######
SAct.SetCls("ActionPress","Police.GetGear")
##### Police Sounds #####
import PoliceSound;PoliceSound.Init("Police")
##### Police Effects #####
import Fx
if not Init.OutMapSkip :
Scrap.Set("FXPoliceStealFile",FXPoliceStealFile)
Scrap.SetDebrisSys(FXPoliceStealFile,1,0,0,1,0,0,Fx.FXPOLICESTEAL)
Scrap.Set("FXPoliceGearConversionFile",FXPoliceGearConversionFile)
Scrap.SetDebrisSys(FXPoliceGearConversionFile,2,0,0,1,0,0,Fx.FXPOLICEGEARCONVERSION)
##### Police Speech #####
import Speech
Speech.SpeechRoutines["Police"] = PoliceSpeech
def OnCreate(EntityName):
e = Scrap.GetEntity(EntityName)
e.TgType = "Green"
import CharAct;CharAct.OnCreate(EntityName)
import PoliceSound; PoliceSound.InitLoops(EntityName)
def OnFreeResources():
import Fx
Scrap.SetDebrisSys(FXPoliceStealFile,0,0,0,1,0,0,Fx.FXPOLICESTEAL)
Scrap.SetDebrisSys(FXPoliceGearConversionFile,0,0,0,1,0,0,Fx.FXPOLICEGEARCONVERSION)
def AbortSiren(EntityName,EventName,Time):
char = Scrap.GetEntity(EntityName)
if char.ActChan1:
char.Action = "SirenEnd" #cuchuflon!
def GetGear(EntityName):
me = Scrap.GetEntity(EntityName)
me.Action = "ActionFusion"
# changeTime = Scrap.GetTime() + SAct.GetAct("AnmTotalTime") + 0.1
# Scrap.AddScheduledFunc(changeTime, ChangeToGear, ())
def ChangeToGear():
import Chars
# Chars.LoadRes("Gear")
# Scrap.UsrEntity(0).ActCtrl="Gear"
# def GetGear(EntityName):
# import Chars, Menu
# global Cam, AuxInterp, newme, me
#
# char = Scrap.GetEntity(EntityName)
# char.Action = "Fusion"
#
# me = Scrap.GetEntity(EntityName)
#
# Cam = Scrap.GetEntity(Scrap.GetCam(0))
#
# # crea el interpolador intermedio
# AuxInterp = Scrap.CreateEntity("AuxInterp",me.Pos[0],me.Pos[1],me.Pos[2],"Obj")
# AuxInterp.Ang = me.ViewAng
#
# if me.Name == "PlayerZ":
# PlName = "Player0"
# else:
# PlName = "PlayerZ"
#
# newme = Chars.CreateMainChar(PlName,Scrap.GetSaveVar("Char"),me.Pos,me.Ang)
#
# AuxInterp.CamTgt = newme.CamTgt
# AuxInterp.MovePos = newme.Pos
# AuxInterp.MoveAng = newme.ViewAng
# AuxInterp.MoveFade = 3
# AuxInterp.MoveTime = SAct.GetAct('AnmTotalTime')
# SAct.GetClass(me.ActCtrl)
# Cam.Fov = SAct.GetCls("FOV")
# Cam.CamDist = SAct.GetCls("CamDist")
# Cam.CamAng = SAct.GetCls("CamAng")
# Cam.CamRot = SAct.GetCls("CamRot")
# Menu.MovieScorer(0)
# SInput.SetActionSet("Inactive")
def GotGear(EntityName, b, c):
import Chars, Menu, CharScorer
global Cam, AuxInterp, newme, me
SInput.SetActionSet("Walk")
Cam.MainTarget = Cam.Target = newme.Name
newme.Energy = me.Energy-1.0
newme.Life = 100
newme.UsrControl = 0
ActCtrl = me.ActCtrl
me.Active = 0
me.ActCtrl = ""
me.Del()
Chars.DiscardRes(ActCtrl)
AuxInterp.Del()
del Cam
del AuxInterp
CharScorer.Create(0)
# comienza a pedir dinero
# def ActionPress(EntityName):
# char = Scrap.GetEntity(EntityName)
# if not char.isFalling:
# char.Action = "ActionInit"
# if char.Action == "ActionInit":
# char.DefLoop = "Action"
# cuando termina el loop de pedir dinero
# def EndActionMoney(EntityName,EventName,Time):
# char = Scrap.GetEntity(EntityName)
# if not char.ActionPress:
# char.ForceDefLoop = "Relax"
# char.ForceAction = "Relax"
# Scrap.GetEntity("DM_Door_Elevator_00").RadarShow = 1
def GoToMission(CharName):
ch = Scrap.GetEntity(CharName)
ch.LLogicGotoMainMission = 1
ResState = 0
##
## Rutina de parloteo del Policia
####################################
def PoliceSpeech(UsrName,CharName,optId,FullOption):
global ResState
import Speech, Chars, Challenge, Menu, CharsNPC
ch = Scrap.GetEntity(CharName)
Speech.PlayerName = UsrName
Speech.NPCName = CharName
charType = "Police"
if (optId == "Talk"):
CharsNPC.CheckActualEntity(CharName)
if ch.LLogicState==10:
Speech.OnSpch("Generics_PoliceWereIsGoInitMsg1","Generics_PoliceWereIsGoInitAns1")
else:
rndval = apply(Scrap.Rand, (1.0 , 3.9) )
if (Speech.OnSpch("Generics_" + charType + "_InitMsg1","Generics_" + charType + "_InitAns"+`int(rndval)`)):
CharsNPC.optionsList, CharsNPC.subOptionsList = CharsNPC.ClassifyOptions(charType)
Speech.StdAnsLst(CharsNPC.optionsList+["Generics_PoliceWereIs"])
numOpts = len(CharsNPC.optionsList)+1
index = 0
if (Scrap.GetSaveVar("Player.InfiniteLives") == "0"):
Challenge.AddChallenge(ch, UsrName, numOpts)
elif (optId in CharsNPC.optionsList):
if Speech.OnSpch(optId + "Msg", optId + "Ans"):
index = CharsNPC.optionsList.index(optId)
index = index + 1
CharsNPC.IncludeSubOptions(optId)
Speech.StdAnsLst(CharsNPC.optionsList+["Generics_PoliceWereIs"])
numOpts = len(CharsNPC.optionsList)+1
ch.ArriOpt = index
if (Scrap.GetSaveVar("Player.InfiniteLives") == "0"):
Challenge.AddChallenge(ch, UsrName, numOpts)
elif optId=="Generics_PoliceWereIs":
ch.LLogicGotoMainMission = 1
ch.LLogicState = 0
ch.LLogicIdle = 1
if ch.LLogicPoliceResult == 0:
Speech.OnSpch("Generics_PoliceWereIsMsg","Generics_PoliceWereIsNo")
ch.ArriOpt = 0
else:
Speech.OnEndOfSpeech = GoToMission
Speech.OnEndOfSpeechParams = (ch.Name,)
Speech.OnSpch("Generics_PoliceWereIsMsg","Generics_PoliceWereIsYes")
Speech.RestoreState(CharName)
elif optId=="ChallengeRaceStdOpt0":
if Speech.OnSpch("ChallengeRace" + charType + "Opt1","ChallengeRace" + charType + "Msg1"):
Challenge.challengeType = "Race"
Challenge.foeType = charType
Challenge.SetChallengeOptions(ch)
elif optId=="ChallengeCombatStdOpt0":
if Speech.OnSpch("ChallengeCombat" + charType + "Opt1","ChallengeCombat" + charType + "Msg1"):
Challenge.challengeType = "Combat"
Challenge.foeType = charType
Challenge.SetChallengeOptions(ch)
elif optId=="ChallengeRaceStdOpt1":
Challenge.OnChallengeOpt(1, ch)
elif optId=="ChallengeRaceStdOpt2":
Challenge.OnChallengeOpt(2, ch)
elif optId=="ChallengeRaceStdOpt3":
Challenge.OnChallengeOpt(3, ch)
elif optId=="ChallengeRaceStdOpt4":
if Speech.OnSpch("ChallengeRaceStdOpt2","ChallengeRace" + charType + "Msg3"):
Speech.StdAnsLst(CharsNPC.optionsList)
numOpts = len(CharsNPC.optionsList)
Challenge.AddChallenge(ch, UsrName, numOpts)
index = 0
elif optId=="GiveWhy": # Preguntarle por que es tan cabron
if Speech.OnSpch("Generics_PoliceBribeGiveWhyAns","Generics_PoliceBribeGiveWhyMsg"):
ResState = 0
ch.ForceAction = "FaceToTalk"
ch.ForceDefLoop = "TalkListenNPC"
Speech.OnEndOfSpeech = OnEndOfSpeech
elif optId=="GiveYes": # darle soborno al policia
if Scrap.GetMoney()>=Scrap.Get("PoliceStealQuanto"):
Scrap.SetMoney(Scrap.GetMoney()-Scrap.Get("PoliceStealQuanto"))
Scrap.SetAlarm(0)
# pierdes tu preciado dinero
ResState = 1
ch.LLogicState = 0
ch.LLogicTarget = ""
ch.ForceAction = "Relax"
ch.ForceDefLoop = "Relax"
if Speech.OnSpch("Generics_PoliceBribeGiveYesAns","Generics_PoliceBribeGiveYesMsg"):
Speech.OnEndOfSpeech = OnEndOfSpeech
else:
# creo que no puedes pagarle
if Speech.OnSpch("Generics_PoliceBribeCantDoAns","Generics_PoliceBribeCantDoMsg"):
ResState = 0
ch.ForceAction = "FaceToTalk"
ch.ForceDefLoop = "TalkListenNPC"
Speech.OnEndOfSpeech = OnEndOfSpeech
elif optId=="GiveNo": # no darle ni una mierda al policia
if Scrap.Rand(0,100) < 50:
# se cabrea
ch = Scrap.GetEntity(Speech.NPCName)
me = Scrap.GetEntity(Speech.PlayerName)
if Speech.PlayerAns(me,ch,"Generics_PoliceBribeGiveNoAns",OnEndOfSpeech):
ResState = -1
Speech.OnEndOfSpeech = OnEndOfSpeech
else:
# no se cabrea pero te advierte!
ch.LLogicState = 0
ch.LLogicTarget = ""
ch.ForceAction = "Relax"
ch.ForceDefLoop = "Relax"
Speech.OnSpch("Generics_PoliceBribeGiveNoAns","Generics_PoliceBribeGiveNoMsg")
else:
print "Error PoliceSpeech(",UsrName,CharName,optId,FullOption,")"
PoliceSpeech(UsrName,CharName,"Talk",FullOption)
def OnEndOfSpeech():
import Speech
ch = Scrap.GetEntity(Speech.NPCName)
me = Scrap.GetEntity(Speech.PlayerName)
if ResState==1:
if (ch):
ch.ForceAction = "ActionOK"
Scrap.SetCallFunc("!FXPoliceSteal")
Scrap.AddParams(Speech.NPCName)
Scrap.AddParams(me.Name)
Scrap.Execute()
elif ResState==-1:
if (ch):
ch.LLogicPoliceResult = -1
me.ForceAction = "Relax"
me.ForceDefLoop = "Relax"
me.AutoSelect = 1
else:
if (ch):
if ch.Action[0:5] == "Relax":
ch.LLogicIdle = ResState
ch.LLogicPoliceResult = ResState
ch.ForceAction = "ActionNPC"
ch.ForceDefLoop = "ActionNPC"
ch.SelectedEntity = Scrap.UsrEntity(0).Name

75
README.md Normal file
View file

@ -0,0 +1,75 @@
# Scrapland Mods
This repository is a just mine playground where I learn how to mod Scrapland and
try to make something useful and/or fun. Don't take this repository too serous.
It is no near good example on moding Scrapland. I am just plaing around here 😅.
## Requirements
For building `.packed` files in scripts I use [ScrapPackedExplorer](https://github.com/romibi/Scrap-Packed-Explorer).
If you want to use my scripts you need to use ScrapPackedExplorer >= 0.3.1.
For compiling `.py` to `.pyc` you need [Python 1.5.2](https://www.python.org/download/releases/1.5/).
And preferably you need to have any verison of Scrapland itself 😄.
## build.ps1
`build.ps1` is a script that can build, insatll and uninstall mods fromt this
repo.
### Setup
To use `build.ps1` you need specify 3 varables at the top of the script: path to
ScrapPackedExplorer, Python 1.5.2 and Scrapland:
```powershell
$pack_expl_path = '..\bins\spe.exe';
$pyhton_path = 'C:\Program Files (x86)\Python\python.exe';
$scrapland_path = 'D:\Games\SteamLibrary\steamapps\common\Scrapland';
```
### How to use it
Building mods:
```powershell
.\build.ps1 # If no argument specified will build all folders except 'bin' and 'out'
.\build.ps1 ModName # Will build mod from folder "ModName"
```
Flags:
```powershell
.\build.ps1 -i --install # Installs mod after building it
.\build.ps1 -u --uninstall # Instead of building mod will uninstall it
```
Mods will be in the `out` folder
Every folder is a separate mod.
## Mods structure
There is 2 types of "configuration" of mod folder: *simple* and *with misc*
### Simple mod
Everyting in mod folder will be packed in `.packed` file. That's it. Pretty
simple.
### Mod with misc
```
..
ModFolder\
|__ packed\
|____ ...
|__ misc\
|____ ...
```
Everyting in `packed` folder will be packed in `.packed` file.
Everyting in `misc` folder will be copied to the game folder. If that file is
aredy exists, original file will be backed-up and re-installed on its place on
uninstalling mod.

View file

@ -0,0 +1,7 @@
# Scorer Playground
For now this is playground for learning `SScorer` library.
Plans:
- [ ] Make a library with common GUI elements (buttons, sliders, menus etc)
- [ ] Make a more *specific* API for adding your custom settings for your mods

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,167 @@
import Scrap,SInput,SNet,SWeap,SScorer,SVec
def log(msg):
Scrap.Print("[STRNG][MyMenu] " + str(msg) + "\n")
log("Starting module")
# ResetToDefault()
def SetState(var, val):
# log('SetState("' + var + '", ' + str(val) + ')')
Scrap.SetSaveVar(var, str(val))
Scrap.SaveConfig()
def GetState(var, val = None):
# log('GetState("' + var + '")')
result = Scrap.GetSaveVar(var)
if result is None:
return val
else:
return result
MOTD = ""
Menu = None
def MyMenu(id, control):
ResetToDefault()
import Menu
log("Creating mods menu")
Menu.StartNewMenu(id)
Menu.VerticalMenu(id, Scrap.GetLangStr("Menu_Options_Mods"),(
[Scrap.GetLangStr("My_Menu_Test_Bool") + ":", "MyMenu.TestBool" ],
[Scrap.GetLangStr("My_Menu_Test_Counter") + ":", "MyMenu.TestCounter" ],
[Scrap.GetLangStr("My_Menu_Test_Slider") + ":", "Menu.DummyFunc" ],
[Scrap.GetLangStr("Menu_Back"),"Menu.OptionsMenu"]),
"Menu.OptionsMenu", XStart = 310, VerticalStep = 36, YStart = Menu.OptionMenuYStart, Font = "ScrapMedium")
controlName = "TestBool"
caption = ""
if GetState('test_bool') == '0':
caption = "False"
else:
caption = "True"
SScorer.Add(id,controlName,"Text")
SScorer.Set(id,controlName,"Font", "ScrapMedium")
SScorer.Set(id,controlName,"Text", caption)
SScorer.Set(id,controlName,"CentralText", 1)
SScorer.Set(id,controlName,"Align", "Left")
SScorer.Set(id,controlName,"Red",SScorer.Get(0,"Item1","Red"))
SScorer.Set(id,controlName,"Green",SScorer.Get(0,"Item1","Green"))
SScorer.Set(id,controlName,"Blue",SScorer.Get(0,"Item1","Blue"))
SScorer.Set(id,controlName,"X",330)
SScorer.Set(id,controlName,"Y",SScorer.Get(0,"Item1","Y"))
SScorer.Set(id,controlName,"Effect", "Shadow")
SScorer.Set(id,controlName,"OnAccept", "MyMenu.TestBool")
controlName = "TestCounter"
SScorer.Add(id,controlName,"Text")
SScorer.Set(id,controlName,"Font", "ScrapMedium")
SScorer.Set(id,controlName,"Text", str(GetState('test_counter', 0)))
SScorer.Set(id,controlName,"CentralText", 1)
SScorer.Set(id,controlName,"Align", "Left")
SScorer.Set(id,controlName,"Red",SScorer.Get(0,"Item1","Red"))
SScorer.Set(id,controlName,"Green",SScorer.Get(0,"Item1","Green"))
SScorer.Set(id,controlName,"Blue",SScorer.Get(0,"Item1","Blue"))
SScorer.Set(id,controlName,"X",330)
SScorer.Set(id,controlName,"Y",SScorer.Get(0,"Item2","Y"))
SScorer.Set(id,controlName,"Effect", "Shadow")
SScorer.Set(id,controlName,"OnAccept", "MyMenu.TestCounter")
X = 330
Y = SScorer.Get(0, "Item3", "Y") + 5
controlName = "TestSlider"
Menu.SliderMenu(id, controlName, X, Y)
SScorer.Set(id,controlName,"MaxValue", 1 )
SScorer.Set(id,controlName,"ValueStep", 0.1 )
SScorer.Set(id,controlName,"Value", float(GetState('test_slider', 0)) )
SScorer.Set(id,controlName,"OnChange","MyMenu.TestSlider_Change")
controlName = "DummySliderSub"
SScorer.Add(id,controlName,"Text")
SScorer.Set(id,controlName,"Text","")
SScorer.Set(id,controlName,"W",0)
SScorer.Set(id,controlName,"H",0)
SScorer.Set(id,controlName,"OnGainFocus","MyMenu.TestSlider_Sub")
controlName = "DummySliderAdd"
SScorer.Add(id,controlName,"Text")
SScorer.Set(id,controlName,"Text","")
SScorer.Set(id,controlName,"W",0)
SScorer.Set(id,controlName,"H",0)
SScorer.Set(id,controlName,"OnGainFocus","MyMenu.TestSlider_Add")
Menu.LinkLR(id, "TestSlider", "Item3")
Menu.LinkLR(id, "Item3", "TestSlider")
Menu.LinkLR(id, "DummySliderSub", "Item3")
Menu.LinkLR(id, "Item3", "DummySliderAdd")
Menu.DrawBackOptionMenu(id)
def ResetToDefault():
state_vars = ['test_bool', 'test_counter', 'test_slider']
for var in state_vars:
if Scrap.GetSaveVar(var) is None:
Scrap.CreateSaveVar(var, '0')
# Scrap.CreateSaveVar('test_bool', '1')
# Scrap.CreateSaveVar('test_counter', '0')
# Scrap.CreateSaveVar('test_slider', '0')
log("State inited")
def TestBool(id, control):
if GetState('test_bool') == '1':
SetState('test_bool', 0)
SScorer.Set(id, "TestBool", "Text", "False")
else:
SetState('test_bool', 1)
SScorer.Set(id, "TestBool", "Text", "True")
def TestCounter(id, control):
SetState('test_counter', int(GetState('test_counter', 0)) + 1)
SScorer.Set(id, "TestCounter", "Text", str(GetState('test_counter', 0)))
def TestSlider_Change(id, control):
SetState('test_slider', SScorer.Get(id, 'TestSlider', 'Value'))
def TestSlider_Sub(id, control, prevcontrol):
log('TestSlider_Sub')
value = SScorer.Get(id, 'TestSlider', 'Value')
value_step = SScorer.Get(id, 'TestSlider', 'ValueStep')
result = value - value_step
SetState('test_slider', result)
SScorer.Set(id, 'TestSlider', "Value", result)
SScorer.SetDefault(id,prevcontrol)
def TestSlider_Add(id, control, prevcontrol):
log('TestSlider_Add')
value = SScorer.Get(id, 'TestSlider', 'Value')
value_step = SScorer.Get(id, 'TestSlider', 'ValueStep')
result = value + value_step
SetState('test_slider', result)
SScorer.Set(id, 'TestSlider', "Value", result)
SScorer.SetDefault(id, prevcontrol)
log('End of file')

File diff suppressed because it is too large Load diff

190
build.ps1 Normal file
View file

@ -0,0 +1,190 @@
param(
[Parameter()]
[String] $mod_folder,
[Switch] $verbos,
[Switch] $install,
[Switch] $uninstall
)
$pack_expl_path = '.\bins\spe.exe';
$pyhton_path = 'C:\Program Files (x86)\Python\python.exe';
$scrapland_path = 'D:\Games\SteamLibrary\steamapps\common\Scrapland';
$output_path = ".\out"
$pack_expl_name = 'ScrapPackedExplorerCli';
$pack_expl_ver = [version]'0.3.1';
$userless_err_msgs = @(
"ImportError: No module named Scrap",
"ImportError: No module named SAI",
"ImportError: No module named SAct",
"ImportError: No module named SFX",
"ImportError: No module named SInput",
"ImportError: No module named SLogic",
"ImportError: No module named SNet",
"ImportError: No module named SScorer",
"ImportError: No module named SSound",
"ImportError: No module named SVec",
"ImportError: No module named SWeap"
);
$folders_exclude = (
'bins',
'out'
);
function quite_rm($path) {
Remove-Item $path 2>&1 | out-null;
}
function is_string_in_array($string, $array) {
return $null -ne ($string | Where-Object { $array -match $_ });
}
function disable_colorded_output() {
$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;
}
function check_pack_expl() {
if (-not (test-path $pack_expl_path)) {
Write-Output "Error: $pack_expl_name was not found at '$pack_expl_path'. Please download $pack_expl_name >= $pack_expl_ver";
exit 1;
}
# --version outputs to stderr;
$err = (& $pack_expl_path --version) 2>&1;
$spe_version = $err[0].ToString();
$null = $spe_version -match '(?<name>[^\d]+)(?<version>\d.+)';
$name, $version = $Matches['name'].TrimEnd('.').Trim(), [version]$Matches['version'];
$is_pack_expl_good = $name -ne $pack_expl_name -or
$version.Major -lt $pack_expl_ver.Major -or
$version.Minor -lt $pack_expl_ver.Minor -or
$version.Build -lt $pack_expl_ver.Build;
if ($is_pack_expl_good) {
Write-Output "Error: wrong binary at '$pack_expl_path'. $name >= $version needed.";
exit 1;
}
}
function compile_pyhton($mod) {
Push-Location $mod
Get-ChildItem "." -Recurse -Filter *.py | Foreach-Object {
Push-Location $_.Directory.FullName
$file_name = $_.Name
# NOTE: Pyhton will not compile with `pyhton $file_name` because of import errors
# but if we try to import required file it will compile
$output = (& $pyhton_path -c "import $file_name") 2>&1
# Surpressing error messages about Scrap/SInput/etc module not found
if (-not (is_string_in_array $output $userless_err_msgs) -or $v -or $verbos) {
# Additional empty lines for better errorformat parsing in vim. Check .vimrc for more info
Write-Output "$mod/../$file_name";
Write-Output ""
Write-Output $output
Write-Output ""
}
Pop-Location
}
Pop-Location
}
function pack_mod($mod) {
quite_rm "$output_path\$mod.packed";
if (Test-Path $mod\packed\) {
& $pack_expl_path "$output_path\$mod.packed" add -s $mod\packed;
} else {
& $pack_expl_path "$output_path\$mod.packed" add -s $mod\;
}
}
function load_mod($mod) {
unload_mod($mod);
Copy-Item "$output_path\$mod.packed" $scrapland_path\Mods;
}
function unload_mod($mod) {
if (test-path "$scrapland_path\Mods\$mod.packed") {
quite_rm "$scrapland_path\Mods\$mod.packed";
}
}
# TODO: Not just copy. Copy original file and add content of misc to the end
function load_misc($mod) {
if (-not (Test-Path $mod\miscs\)) {
return
}
Copy-Item -Path $mod\mics\* -Destination $scrapland_path\ -Recurse -Force;
}
# TODO:
function unload_misc($mod) {
}
function build_mod($mod) {
compile_pyhton($mod);
pack_mod($mod);
}
function install_mod($mod) {
load_mod($mod);
load_misc($mod);
}
function uninstall_mod($mod) {
unload_mod($mod);
unload_misc($mod);
}
function make_all_mods() {
Get-ChildItem "." -Dir | Foreach-Object {
if (-not (is_string_in_array $_.Name $folders_exclude)) {
make_mod($_.Name);
}
}
}
function uninstall_all_mods() {
Get-ChildItem "." -Dir | Foreach-Object {
if (-not (is_string_in_array $_.Name $folders_exclude)) {
uninstall_mod($_.Name);
}
}
}
function make_mod($mod) {
build_mod($mod);
if ($install) {
install_mod($mod);
}
}
function main() {
disable_colorded_output;
check_pack_expl;
if (-not $mod_folder) {
if ($uninstall) { uninstall_all_mods; } else { make_all_mods; }
return;
}
if (is_string_in_array $mod_folder $folders_exclude) {
return;
}
if ($uninstall) { uninstall_mod($mod_folder); } else { make_mod($mod_folder); }
}
main