Autor Wątek:  How can I use SetDamage in events?  (Przeczytany 1868 razy)

0 użytkowników i 1 Gość przegląda ten wątek.

Offline manolollr

  • Wiadomości: 27
    • Zobacz profil
  • Otrzymane polubienia: 10
How can I use SetDamage in events?
« dnia: 10 Listopada 2023, 14:27:10 »
Hi! I'm doing experiments with events. I've modified TD scenery a little to include some events. This is my code:

//event keyctrl08 multiple 0.1 none przej_1_zamykaj przej_2_zamykaj endevent
//event keyctrl09 multiple 0.1 none przej_1_otwieraj przej_2_otwieraj endevent

//Posar en marxa el tren
node -1 0 ep07_sta memcell 1.0 1.0 1.0 Wait_for_orders 0 0 start endmemcell
event keyctrl08 updatevalues 0.1 ep07_sta Prepare_engine 1 0 endevent

//Trencar el motor
event keyctrl09 updatevalues 0.1 ep07_sta SetDamage 32 1 endevent


The comments are written in catalan, my native language, they mean "start train" and "break engine"

I've added a second trainset, so the original trainset is controlled by the AI. The "Prepare_engine" works without problem, when you press Shift - 8 the AI starts engine automatically, but "SetDamage"  command is not working, you press Shift - 9 and appears this in the log:

Key pressed: [Shift]+[9]
EVENT ADDED TO QUEUE: keyctrl09
EVENT LAUNCHED: keyctrl09
Type: UpdateValues & Track command - [SetDamage] [32.00] [1.00]
 Memcell: ep07_sta - [SetDamage] [32.00] [1.00]
 Vehicle: [ep07-424]

Apparently the "SetDamage" command has executed correctly, but it does nothing, engine is not broken.

How can I use SetDamage? In my opinion it's a very interesting command because it can introduce random malfunctions.

Offline manolollr

  • Wiadomości: 27
    • Zobacz profil
  • Otrzymane polubienia: 10
Odp: How can I use SetDamage in events?
« Odpowiedź #1 dnia: 11 Listopada 2023, 13:43:34 »
You can send commands to AI trains without the need of events, using simulator debug functionality:

Activate debug, open Map and right click on an AI train. You will see a window to send commands.

Almost all the commands work, but I haven't been able to get some to work: SetDamage, SetLights...

Offline manolollr

  • Wiadomości: 27
    • Zobacz profil
  • Otrzymane polubienia: 10
Odp: How can I use SetDamage in events?
« Odpowiedź #2 dnia: 11 Listopada 2023, 14:18:47 »
I've made it!! I broke the engine!! In older versions of Maszyna was easier to break the engine, in newer versions is more difficult. Here is how I've made it:

The source code of Maszyna is at GitHub:
https://github.com/eu07/maszyna

At McZapkie/Mover.cpp there is this code, at line 433:

    // awarie
    MotorCurrent = abs(Im); // zmienna pomocnicza

if (MotorCurrent > 0)
{
if (FuzzyLogic(abs(n), nmax * 1.1, p_elengproblem))
if (MainSwitch(false))
EventFlag = true; /*zbyt duze obroty - wywalanie wskutek ognia okreznego*/
if (TestFlag(DamageFlag, dtrain_engine))
if (FuzzyLogic(MotorCurrent, (double)ImaxLo / 10.0, p_elengproblem))
if (MainSwitch(false))
EventFlag = true; /*uszkodzony silnik (uplywy)*/
if ((FuzzyLogic(abs(Im), Imax * 2, p_elengproblem) ||
FuzzyLogic(abs(n), nmax * 1.11, p_elengproblem)))
/*       or FuzzyLogic(Abs(U/Mn),2*NominalVoltage,1)) then */ /*poprawic potem*/
if ((SetFlag(DamageFlag, dtrain_engine)))
EventFlag = true;
/*! dorobic grzanie oporow rozruchowych i silnika*/
}

According to the code there is a way to break the engine, run the locomotive 11% faster than maximum allowed engine rotation speed (nmax), for EP07-424 in TD scenery nmax is 2390 RPM, you can see it at file: dynamic/pkp/303e_v1/303e-ep.fiz You can edit this file and set nmax to a lower value, for example 1500, to make it easier to break the engine.
Then uncouple locomotive and drive it at high speed, open debug window with F12 key and observe the parameter "Revolutions: Engine:", it should be higher than 1665 (11% higher than 1500).
The circuit breaker will trip many times, because of excessive engine rotation speed. Rearm it and keep driving at high speed, after a few minutes the engine will be broken.

With the engine broken you can't use it at intensity higher than 60A, well, it doesn't work. You can repair it stopping locomotive and going to engine room (Home or End keys). There press Ctrl - E keyboard shortcut to repair it.

It will be very interesting to add more malfunctions to Maszyna, for example, a malfunction in main brake regulator (FV4a valve), forcing you to use emergency brake valve.
« Ostatnia zmiana: 11 Listopada 2023, 14:21:47 wysłana przez manolollr »

Offline Ra

  • Zasłużony dla Symulatora
  • Wiadomości: 6308
  • Ostatni gasi światło...
    • Zobacz profil
    • Instalator+Starter+Edytor
  • Otrzymane polubienia: 337
Odp: How can I use SetDamage in events?
« Odpowiedź #3 dnia: 11 Listopada 2023, 14:54:23 »
This code is related to damage at runtime, while SetDamage should be processed in event handling.

¯\_( ͡° ͜ʖ ͡°)_/¯ Ra

Polecam: kręgarz Wojciech Walczak, projekt masarni