res/scripts not containing pyc files
Published by Cresh on
BLACKWOT › Forums › Sales, Feedback and Information › Peer to Peer Technical Support › res/scripts not containing pyc files
- This topic has 5 replies, 2 voices, and was last updated 8 years, 7 months ago by picknicker.
-
AuthorPosts
-
18.01.2018 at 12:33 #114254CreshMember
I want to start writing mods for WoT. Python itself is not the problem, but I can’t find the pyc files in the WoT directory which I have to decompile. My res/scripts folder is empty for example.
So where can I find the WoT pyc files?
18.01.2018 at 14:43 #114255picknickerParticipantHey Cresh,
you must unzip them from World_of_Tanksrespackagesscripts.pkg.
Just use 7-zip on that file.
I decompile them with uncompyle2 using this script:
cd scripts chmod -R a+rwx * uncompyle2 -o . --py . rm `find -name "*.pyc"`
This decompiles all pyc files and then deletes them. You will get a few errors for some files which cannot be decompiled, but the major ones work, I usually get along fine.
It would be of course nicer if WG offered a reasonable API instead of all the function hooking, but that’s the way it is…
There used to be an unofficial Bigworld API online which was a great starting point for me, maybe google it (WOT uses the Bigworld 3D engine)
If you can’t find it I might have an offline version of it lying around.
18.01.2018 at 19:53 #114256CreshMember5 hours ago, picknicker said:Hey Cresh,
you must unzip them from World_of_Tanksrespackagesscripts.pkg.
Just use 7-zip on that file.
I decompile them with uncompyle2 using this script:
cd scripts chmod -R a+rwx * uncompyle2 -o . --py . rm `find -name "*.pyc"`
This decompiles all pyc files and then deletes them. You will get a few errors for some files which cannot be decompiled, but the major ones work, I usually get along fine.
It would be of course nicer if WG offered a reasonable API instead of all the function hooking, but that’s the way it is…
There used to be an unofficial Bigworld API online which was a great starting point for me, maybe google it (WOT uses the Bigworld 3D engine)
If you can’t find it I might have an offline version of it lying around.
Thanks! I already found these pkg files but somehow I overlooked the scripts.pkg
I don’t really understand it too. They could at least release a documentation of the functions. I wonder why nobody made some kind of Wiki yet to document the functions. It would be very helpful.
19.01.2018 at 09:15 #114257picknickerParticipant13 hours ago, Cresh said:I don’t really understand it too. They could at least release a documentation of the functions. I wonder why nobody made some kind of Wiki yet to document the functions. It would be very helpful.
Yepp, the saddest part is the “API” we use by hooking random functions is anything else but stable…
Be prepared to debug your mods after every second patch, because WG refactored their code:
Best example: In the Halloween patch last year they introduced a new functionality: two turrets. Broke every aimbot incuding mine. After the event they reverted the code, broke the aimbot again. It was a pretty easy fix, but sometimes they are hard to spot.
I suggest for starting try to find open source mods or mods you can decompile, they are a good basis. If you have a specific question on a functionality just ask, I’ll do my best to help.
I’m pretty sure there is some russian forum (wich google crawlers don’t get to) where all the API changes are discussed. Koreanrandom is so far the best source for me, but the hints are very scattered through the threads and google translate is not always optimal…
But then again: Maybe the BWmod authors know a place, at least they have a business model which needs to react to changes fast, otherwise they loose customers…
19.01.2018 at 14:09 #114258CreshMember4 hours ago, picknicker said:Yepp, the saddest part is the “API” we use by hooking random functions is anything else but stable…
Be prepared to debug your mods after every second patch, because WG refactored their code:
Best example: In the Halloween patch last year they introduced a new functionality: two turrets. Broke every aimbot incuding mine. After the event they reverted the code, broke the aimbot again. It was a pretty easy fix, but sometimes they are hard to spot.
I suggest for starting try to find open source mods or mods you can decompile, they are a good basis. If you have a specific question on a functionality just ask, I’ll do my best to help.
I’m pretty sure there is some russian forum (wich google crawlers don’t get to) where all the API changes are discussed. Koreanrandom is so far the best source for me, but the hints are very scattered through the threads and google translate is not always optimal…
But then again: Maybe the BWmod authors know a place, at least they have a business model which needs to react to changes fast, otherwise they loose customers…
I think I found the site of the BigWorld API which you’ve suggested me. Did you mean this one: http://monstrofil.xyz/docs/doc/api_python/client/index.html ?
The only open-source mod I’ve found yet is the teamspeak mod. I tried to decompile several mods, but all of them are protected by PjOrion. I tried unpacking it, but sooner or later I failed on each single one.
I already browsed a bit of KoreanRandom. I was surprised how good Google Translate is working.
What exactly do you mean by hooking functions? Until now I’ve only seen that you implement something new into the game and access some API functions. But I haven’t seen function hooking yet.
Well it seems like beginning to learn WoT modding is pretty tough…
19.01.2018 at 15:45 #114259picknickerParticipantRegarding other mods: Depends what you wanna do, but since you are here I guess you are interested in the “less legal mods”. XVM is open source as well, so you might wanna take a look there. I was recently really surprised how they solved this XMQP interface (if activated, you actually send minimap/sixth sense data via their server using the pika protocol): https://bitbucket.org/XVM/xvm/src/f19902a448ddb0f1887cd7939ea9dac9b57ce7eb/src/xpm/xvm_battle/xmqp.py?at=default&fileviewer=file-view-default
Hooking:
Now this is some code I once grabbed from some other mod (I don’t know anymore which one it was so sorry to the original author):
class HookLib(object): ORIGIN_BEFORE = 0 ORIGIN_INSIDE = 1 HOOK_BEFORE = 2 CALL_DEFAULT = ORIGIN_BEFORE def __init__(self, origin, hook, type = CALL_DEFAULT, active = True): if not isinstance(hook, (types.FunctionType, types.LambdaType)): raise TypeError('Hook must be function or lambda') self.__name__ = hook.__name__ self.origin = origin self.hook = hook self.type = type self.active = active def __call__(self, *args, **kwargs): if self.active and self.type == self.ORIGIN_BEFORE: result = self.origin(*args, **kwargs) self.hook(*args, **kwargs) elif self.active and self.type == self.ORIGIN_INSIDE: result = self.hook(self.origin, *args, **kwargs) elif self.active and self.type == self.HOOK_BEFORE: self.hook(*args, **kwargs) result = self.origin(*args, **kwargs) else: result = self.origin(*args, **kwargs) return result def __get__(self, instance, type = None): return types.MethodType(self, instance, type) @classmethod def makeMethodHook(cls, target, method, hook, type = CALL_DEFAULT, active = True): origin = getattr(target, method).__func__ override = cls(origin, hook, type, active) if isinstance(target, (types.TypeType, types.ClassType)): setattr(target, method, override) else: setattr(target, method, override.__get__(target, types.TypeType(target))) return hook @classmethod def methodHook(cls, target, method, type = CALL_DEFAULT, active = True): return functools.partial(cls.makeMethodHook, target, method, type=type, active=active)
Now in order to actually hook a function like e.g. PlayerAvatar.showVehicleDamageInfo
*cough* autofireextinguisher anyone? *cough*
@HookLib.methodHook(PlayerAvatar, 'showVehicleDamageInfo', HookLib.HOOK_BEFORE) def showVehicleDamageInfo(self, vehicleID, damageIndex, extraIndex, entityID, equipmentID): #do sommething before the actual function is called
Now i wrote the last bit from my head, so it might not compile immediately, but I guess you get the point.
-
AuthorPosts
- You must be logged in to reply to this topic.