pipje2001 Posted March 6, 2019 Share Posted March 6, 2019 I just started trying to make my own mod, but i have absolutely no experience with modding for any game. I do know the basics of python so that shouldn't be a big problem. So far i tried to follow this short tutorial https://bitbucket.org/_vb_/wot.mods/wiki/GettingStarted with the help of google translate. # -*- coding: utf-8-sig -*- import BigWorld from gui import SystemMessages from Account import Account #file for using philips hue in python from mod_phue import Bridge #some stuff needed for philips hue b = Bridge('192.168.1.101') listOfLight = b.lights def hello(self): parent(self) SystemMessages.pushMessage('Hello WoT!', type=SystemMessages.SM_TYPE.Warning) #sets the ligt red b.set_light(4, 'xy', [0.1938, 0.6821], transitiontime=10) b.set_light(5, 'xy', [0.1938, 0.6821], transitiontime=10) #sets the ligt on max brightness b.set_light(4, 'bri', 254, transitiontime=10) b.set_light(5, 'bri', 254, transitiontime=10) Account.onBecomePlayer = parent parent = Account.onBecomePlayer Account.onBecomePlayer = hello with some modifications i got the lights to change to red and on max brightness, so it is possible to control the lights with a mod, but i am trying to make the lights flash when i get hit. But i guess i have to use onHealthChanged but i have no idea how. If somebody could help me it would be appreciated @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 6, 2019 Share Posted March 6, 2019 (edited) 1 hour ago, pipje2001 said: But i guess i have to use onHealthChanged but i have no idea how. Like this: from Vehicle import Vehicle from random import randint from time import sleep def _set_brightness(value): b.set_light(4, 'bri', value, transitiontime=10) b.set_light(5, 'bri', value, transitiontime=10) def new_onHealthChanged(self, newHealth, attackerID, attackReasonID): old_onHealthChanged(self, newHealth, attackerID, attackReasonID) if not self.isPlayerVehicle: return #make light randomly flashes for 10 times for _ in range(10): _set_brightness(randint(0, 254)) sleep(0.1) #restore brightness to default _set_brightness(254) old_onHealthChanged = Vehicle.onHealthChanged Vehicle.onHealthChanged = new_onHealthChanged Edited March 6, 2019 by Kotyarko_O @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 6, 2019 Author Share Posted March 6, 2019 @Kotyarko_O Awesome, that really helped me, although i still have some more questions though. is it possible to get the currunt hp and max hp of the tank you are playing at that moment? and is there somewhere where i can find information about an ingame settings window for my own mod? like some populair mods have? @ Quote Link to comment Short link Share on other sites More sharing options...
spoter Posted March 6, 2019 Share Posted March 6, 2019 try this https://github.com/spoter/spoter-mods https://github.com/GambitER/GUIFlash https://github.com/PolyacovYury/PYmods https://github.com/Aimdrol/WoT-Replay-Analyzer and more and more @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 6, 2019 Share Posted March 6, 2019 (edited) 29 minutes ago, pipje2001 said: is it possible to get the currunt hp and max hp of the tank you are playing at that moment? Sure: from BigWorld import player from PlayerEvents import g_playerEvents from Vehicle import Vehicle maxHp = None curHp = None def setMaxHp(): global maxHp plVeh = player().getVehicleAttached() maxHp = plVeh.typeDescriptor.maxHealth def new_onHealthChanged(self, newHealth, attackerID, attackReasonID): old_onHealthChanged(self, newHealth, attackerID, attackReasonID) if not self.isPlayerVehicle: return global curHp curHp = newHealth def reset(): global maxHp, curHp maxHp = None curHp = None g_playerEvents.onAvatarBecomePlayer += setMaxHp # old_onHealthChanged = Vehicle.onHealthChanged Vehicle.onHealthChanged = new_onHealthChanged # g_playerEvents.onAvatarBecomeNonPlayer += reset May be mistakes\errors, didn`t test it. 29 minutes ago, pipje2001 said: is there somewhere where i can find information about an ingame settings window for my own mod? like some populair mods have? https://bitbucket.org/P0LIR0ID/wot-modslist/src/master/ https://bitbucket.org/The_IzeBerg/modssettingsapi/src/master/ (https://kr.cm/f/t/48259/) https://kr.cm/f/t/25477/c/279913/ Almost all of this utils have only russian description, unfortunasdljsklfjdfkh (can`t remember all letters in this word). Edited March 6, 2019 by Kotyarko_O @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 7, 2019 Author Share Posted March 7, 2019 (edited) I looked trough the links you send but i dont understand shit about how it works XD, for example if i want to set the ip of the bridge in the game. b = Bridge('192.168.1.101') what would i need to make this possible? And how do you get the playerid of the player which i am playing with? never mind already found it (BigWorld.player().playerVehicleID) Edited March 7, 2019 by pipje2001 @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 7, 2019 Author Share Posted March 7, 2019 @Kotyarko_O the code you send doesn't seem to be working, although i changed some of it i can't find what is wrong import BigWorld from PlayerEvents import g_playerEvents from Vehicle import Vehicle from random import randint import time import threading #file for using philips hue in python from mod_phue import Bridge #some stuff needed for philips hue b = Bridge('192.168.1.101') listOfLight = b.lights maxHp = None curHp = None def DamageRecievedSmall(): b.set_light(4, 'xy', [0.678, 0.3168], transitiontime=0) b.set_light(4, 'bri', 254, transitiontime=0) time.sleep(0.2) b.set_light(4, 'bri', 0, transitiontime=3) print("DRS_Done") def DamageRecievedLarge(): b.set_light(4, 'xy', [0.678, 0.3168], transitiontime=0) b.set_light(4, 'bri', 254, transitiontime=0) time.sleep(0.6) b.set_light(4, 'bri', 0, transitiontime=3) print("DRL_Done") def setMaxHp(): global maxHp plVeh = BigWorld.player().getVehicleAttached() maxHp = plVeh.typeDescriptor.maxHealth def new_onHealthChanged(self, newHealth, attackerID, attackReasonID): old_onHealthChanged(self, newHealth, attackerID, attackReasonID) print(attackerID) print(attackReasonID) print(BigWorld.player().playerVehicleID) if not self.isPlayerVehicle: if attackerID != BigWorld.player().playerVehicleID: return global curHp curHp = newHealth # if attackerID == BigWorld.player().playerVehicleID: # t3 = threading.Thread(target=hue3) # t4 = threading.Thread(target=hue4) # if t3.isAlive()==False: # print("hue3start") # t3.start() # if t4.isAlive()==False: # print("hue4start") # t4.start() if attackerID != BigWorld.player().playerVehicleID: if curHp/maxHp <= 0.2: DRS = threading.Thread(target=DamageRecievedSmall) if DRS.isAlive()==False: DRS.start() print("DRS_Start") if curHp/maxHp > 0.2: DRL = threading.Thread(target=DamageRecievedLarge) if DRL.isAlive()==False: DRL.start() print("DRL_Start") def reset(): global maxHp, curHp maxHp = None curHp = None g_playerEvents.onAvatarBecomePlayer += setMaxHp old_onHealthChanged = Vehicle.onHealthChanged Vehicle.onHealthChanged = new_onHealthChanged g_playerEvents.onAvatarBecomeNonPlayer += reset @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 7, 2019 Share Posted March 7, 2019 @pipje2001, any errors in python.log? @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 7, 2019 Author Share Posted March 7, 2019 @Kotyarko_Oo i see i forgot to add them Traceback (most recent call last): File "scripts/common/Event.py", line 44, in __call__ File "mod_hello", line 40, in setMaxHp File "scripts/client/avatar_components/AvatarObserver.py", line 260, in getVehicleAttached AttributeError: 'PlayerAvatar' object has no attribute 'playerVehicleID' @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 7, 2019 Share Posted March 7, 2019 14 minutes ago, pipje2001 said: AttributeError: 'PlayerAvatar' object has no attribute 'playerVehicleID' My bad. Try to use "onAvatarReady" instead of "onAvatarBecomePlayer". @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 7, 2019 Author Share Posted March 7, 2019 @Kotyarko_O and what about the onAvatarBecomeNonPlayer @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 7, 2019 Share Posted March 7, 2019 3 minutes ago, pipje2001 said: onAvatarBecomeNonPlayer It`s ok. This is "leave battle" event. @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 7, 2019 Author Share Posted March 7, 2019 @Kotyarko_O Awesome, i got one more problem though, i try to run this code in a loop: def LowHp(): while curHp > 0: b.set_light(1, 'xy', [0.678, 0.3168], transitiontime=0) b.set_light(1, 'bri', 254, transitiontime=10) time.sleep(1) b.set_light(1, 'bri', 0, transitiontime=10) time.sleep(1) print("LH_Done") But i only want this function to run once at a time so i use this method to check if the tread is already running but it "forgets" that its running so the next time i get shot it just runs it again which kinda breaks my lights XD if fcurHp/fmaxHp <= 0.1: LH = threading.Thread(target=LowHp) print(LH.is_alive()) if not LH.is_alive(): LH.start() print("LH_Start") mod_hello.py @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 8, 2019 Share Posted March 8, 2019 (edited) 11 hours ago, pipje2001 said: But i only want this function to run once at a time so i use this method to check if the tread is already running but it "forgets" that its running so the next time i get shot it just runs it again which kinda breaks my lights XD Because every time you get damaged in this condition (fcurHp/fmaxHp <= 0.1), you create another thread and checks it. First of all, "LH" must be a global var. So the code must be like: LH = None ... if fcurHp/fmaxHp <= 0.1: global LH if not (LH and LH.is_alive()): LH = threading.Thread(target=LowHp) LH.start() print("LH_Start") Edited March 8, 2019 by Kotyarko_O @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 8, 2019 Author Share Posted March 8, 2019 @Kotyarko_O Thanks, that did the trick, do you mind if i ask you some more questions? - how do you know if the tank is on fire? - how do you know if modules are hit? and which module is hit? - and how can you make a settings window in the game? I tried to search for answers but because most stuff is in russian searching is kinda difficult @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 8, 2019 Share Posted March 8, 2019 1 hour ago, pipje2001 said: - how do you know if the tank is on fire? from gui.Scaleform.daapi.view.meta.DamagePanelMeta import DamagePanelMeta isVehInFire = False old_setFireInVehicleS = DamagePanelMeta.as_setFireInVehicleS def new_setFireInVehicleS(self, isInFire): global isVehInFire isVehInFire = isInFire DamagePanelMeta.as_setFireInVehicleS = new_setFireInVehicleS 2 hours ago, pipje2001 said: - how do you know if modules are hit? and which module is hit? Example: https://bitbucket.org/Kotyarko_O/xvm.py_macro/src/19fbaa0b1c298ccc87bd20a2b0dfce320ef981e4/repairControl/repairControl.py#lines-260 2 hours ago, pipje2001 said: - and how can you make a settings window in the game? Guide: https://kr.cm/f/t/25477/c/279913/ (a bit outdated). Example: https://bitbucket.org/Kotyarko_O/modpack_updatesannouncer-moder/src/master/ @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 9, 2019 Author Share Posted March 9, 2019 (edited) @Kotyarko_O I tried using https://bitbucket.org/The_IzeBerg/modssettingsapi/src and https://bitbucket.org/P0LIR0ID/wot-modslist/src/ce1e5c1d2662?at=master, but i can't find where the settings are saved and how is can access them from my own mod... for example i want to be able to set the ip adress of the hub in the settings menu, but i have no idea how mod_hello.py mod_modsettings.py Edited March 9, 2019 by pipje2001 added some files @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 9, 2019 Share Posted March 9, 2019 4 minutes ago, pipje2001 said: but i can't find where the settings are saved and how is can access them from my own mod... https://bitbucket.org/The_IzeBerg/modssettingsapi/src/0570eaea89ae85d3817422aa6487bd17eebb6530/mod_modsettingsexample.py#lines-113 @ Quote Link to comment Short link Share on other sites More sharing options...
pipje2001 Posted March 9, 2019 Author Share Posted March 9, 2019 @Kotyarko_O still don't understand it though, how do i get the value from the textinput into my own mod? and how can i run a function in my mod when i press apply in the settings menu? @ Quote Link to comment Short link Share on other sites More sharing options...
Kotyarko_O Posted March 9, 2019 Share Posted March 9, 2019 (edited) 8 minutes ago, pipje2001 said: how do i get the value from the textinput into my own mod? and how can i run a function in my mod when i press apply in the settings menu? When apply button pressed, event "onModSettingsChanged" is performed. In thatfunction you can do what you need to do. For example: def onModSettingsChanged(linkage, newSettings): if linkage == modLinkage: setNewSettings(newSettings) def setNewSettings(settings): print settings['textInput'] I`m not sure that "settings['textInput']" is correct. You need to test it. I don`t know what exactly contains "newSettings"-argument. Edited March 9, 2019 by Kotyarko_O @ Quote Link to comment Short link Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.