nipkownix / re4_tweaks

Fixes and tweaks for the "UHD" port of Resident Evil 4
zlib License
339 stars 33 forks source link

Tool to Edit Enemy Speed #243

Open DarthxVoid opened 2 years ago

DarthxVoid commented 2 years ago

Describe the feature you'd like to see added

It would be nice a tool that you could edit the speed and size of each enemy in RE4, It would be very useful for challenges and making mods

Mister-Curious commented 2 years ago

These two features do exist in Raz0r's trainer, but only seem to work on Ganados, Zealots and Commandos. I think it is done by changing the speed of the animations themselves, as when I added custom animations to my Ganado's that trainer feature stopped working.

Since this has already been accomplished with the trainer, it should be easy enough to observe in ChearEngine and duplicate. @emoose maybe these two features could be added to the list of features we were hoping to plug into the debug flags? Have you had any time to try some of those out?

DarthxVoid commented 2 years ago

These features of the Raz0r trainer is very strange with certain types of id like Verdugo, but the Raz0r's besides being flawed you change them all I would like to be able to change the size and speed per separate id and each one can have a different size and different speed, something that you can't do with Raz0r's trainer, besides of course his trainer causes a lot of crash in the game

DarthxVoid commented 2 years ago

@emoose It would be possible to have in the tool An option that you can choose the enemy id you want to edit the speed and size, because the Raz0r has many limitations and doesn't work right, It would be very interesting if you could have enemies of different size and speed in your game

emoose commented 2 years ago

Did a little work on this, managed to get it changing enemy speed with https://github.com/emoose/re4_tweaks/commit/8b5fd5835710526cdc8e656ebf6b80017c449969 & https://github.com/emoose/re4_tweaks/commit/61287e6138c12499341ede03b711814f0f2f0bc0

A test build can be found at https://github.com/emoose/re4_tweaks/actions/runs/2650125997, will need to enable the EnableDebugMenu setting in dinput8.ini, then once in-game open debug menu with CTRL+F3 and choose the max gold option, should double speed of all loaded models each time. (this works pretty much the same way as ditman glitch did, only animation speed is being changed, which can get reset pretty easily when a different anim is played - I don't think custom anims should have an issue with it though, but could be wrong)

This is just a test atm though, maybe sometime in future we could add this to some kind of trainer section in the tweak UI, maybe allow showing a list of all models with values for them that can be adjusted.

kTeo-0 commented 2 years ago

I don't know if that would fit for implementing on RE4 Tweaks, but since you guys added some stuff for modders and utilities in general i think it's worth a shot writing this, maybe even non modders can have a fun time playing with it.

you guys should be aware of Arrange Mode, made by Luis Webber. He uses a custom version of Companion that can be used for setting size/speed values for each individual enemy based on their IDs. for example:

[SpeedSize] Enable = 1 Em0_ID = 0x15 Em0_Outfit = 0x04 Em0_Speed = 118 Em0_Size = 120

Em1_ID = 0x16 Em1_Outfit = 0x0b Em1_Speed = 125 Em1_Size = 85

in this, only 15 04 and 16 0B would be changed from em15 and em16.

I have found another cool trick there as well that lets you change speed and sizes of the same ID:

Em11_ID = 0x2C Em11_Outfit = 0x00 Em11_Speed = 110 Em11_Size = 100

Em32_ID = 0x2C Em32_Outfit = 0x03 Em32_Speed = 160 Em32_Size = 100

Em36_ID = 0x2c Em36_Outfit = 0x10 Em36_Speed = 160 Em36_Size = 100

you see, all of those will spawn a 2C 00 verdugo, the secondary byte does nothing. However, it will still apply the modified speed/size for that single ID. Pretty cool trick!

kTeo-0 commented 2 years ago

I don't know if that would fit for implementing on RE4 Tweaks, but since you guys added some stuff for modders and utilities in general i think it's worth a shot writing this, maybe even non modders can have a fun time playing with it.

you guys should be aware of Arrange Mode, made by Luis Webber. He uses a custom version of Companion that can be used for setting size/speed values for each individual enemy based on their IDs. for example:

[SpeedSize] Enable = 1 Em0_ID = 0x15 Em0_Outfit = 0x04 Em0_Speed = 118 Em0_Size = 120

Em1_ID = 0x16 Em1_Outfit = 0x0b Em1_Speed = 125 Em1_Size = 85

in this, only 15 04 and 16 0B would be changed from em15 and em16.

I have found another cool trick there as well that lets you change speed and sizes of the same ID:

Em11_ID = 0x2C Em11_Outfit = 0x00 Em11_Speed = 110 Em11_Size = 100

Em32_ID = 0x2C Em32_Outfit = 0x03 Em32_Speed = 160 Em32_Size = 100

Em36_ID = 0x2c Em36_Outfit = 0x10 Em36_Speed = 160 Em36_Size = 100

you see, all of those will spawn a 2C 00 verdugo, the secondary byte does nothing. However, it will still apply the modified speed/size for that single ID. Pretty cool trick!

Qingsheng has already found something regarding individual enemy speed: "The address of the speed value is at the value of the enemy pointer + 0x298"

emoose commented 2 years ago

Qingsheng has already found something regarding individual enemy speed: "The address of the speed value is at the value of the enemy pointer + 0x298"

Thanks, that's the same as the offset I change at https://github.com/emoose/re4_tweaks/commit/61287e6138c12499341ede03b711814f0f2f0bc0, good to know I was changing the right spot.

For enemies it seems the speed stays changed even when they use different anims, but changing speed of player gives same issues as ditman glitch did (new anims reset speed back to 1), maybe that's just something that only happens with player char.

Tried looking into changing enemy scale too, but weird thing is that after reducing the scale the enemies seem to grow back to normal height over a few frames, kinda funny to see, with player char it seems to stay at the scale I changed to, but sometimes seems to ignore the new scale, not sure what's up with that, maybe I'm changing the wrong part to get scale changed properly.

DarthxVoid commented 2 years ago

@emoose could you give us the speed hex code and size per enemy id so we can test if it works, this is the functionality we are looking for the most

emoose commented 2 years ago

Eh there's not really a hex edit for it, the way it works is by reading stuff from the game engine, so has to be done in a DLL.

The build I linked at https://github.com/nipkownix/re4_tweaks/issues/243#issuecomment-1180461604 can change the speed as a test, but I'm not sure what the best way to expose that to modders is yet (besides some kind of UI), maybe an INI like the example kTeo posted.

For now made a start on a quick UI though: image

Could probably be useful with some more work, still some bugs with it atm though.

DarthxVoid commented 2 years ago

@emoose you're a GOD, If you manage to implement this function it will be the best update for us modders we have been waiting for this for a long time

FutonGama commented 2 years ago

This is INSANE! I'm free to test everything if you need. Amazing!

emoose commented 2 years ago

Done some cleanup & pushed current code to https://github.com/emoose/re4_tweaks/commit/072407d01e76dea476fc388a6dd4cec7cfce09e1

image

Release build can be found at https://github.com/emoose/re4_tweaks/actions/runs/2656204472 for anyone that wants to try that out, might make a draft PR for it soon too.

The lower PositionChange part can be used to keep applying a certain position change to the position, so you could set the X of that to 100, then each time you press Apply it'll add 100 to position.x. The Position value seems to still get affected by collision somehow so you can't go OOB with that, it might be one of the behavior flags that's affecting it, but not sure... If anyone finds any interesting flags please let us know so we can document them! (E: seems game is checking the new updated position against the old one, if anything is in the way then chara will collide, not really sure where it's storing the old position though, weird stuff)

Not really sure what other cEm related things to add to it atm, if anyone notices any interesting fields inside the structs (pretty much anything from https://github.com/emoose/re4_tweaks/blob/master/dllmain/Game.h#L446 downward) let me know and I'll see about adding it.

FutonGama commented 2 years ago

I'm testing, can we keep the modifications when exit the map?

emoose commented 2 years ago

Small update, figured out how to get position to update without colliding, added a new MapCollision flag, and added Copy position / Paste position buttons to each Em, along with a button to teleport player character to it. (you don't need to change the MapCollision flag if editing position with trainer, but if you want to walk through walls and stuff you can turn it off if you like)

Code at https://github.com/emoose/re4_tweaks/commit/f8a342b5c7734bc6059f73d5b931f43ba7c31c17 Build should be at https://github.com/emoose/re4_tweaks/actions/runs/2656714493 soon.

I'm testing, can we keep the modifications when exit the map?

Some things might be written into save file but trainer itself doesn't save anything, maybe can add stuff to let it read/write an INI file in future.

FutonGama commented 2 years ago

Amazing, and save configuration is essencial for use in the mods, it's hard to add a INI to save? It's the only reason I haven't started using these functions yet, feels already very good to me

DarthxVoid commented 2 years ago

@emoose this is the best update for us modders, seriously we've been wanting this for a long time, we just need the .ini to be able to use it perfectly

emoose commented 2 years ago

Made a start on trainer patches, added an Invincibility patch to the trainer section which should prevent taking damage from enemies, and skips enemy grabs (this works different to other invincibility patches I've seen, didn't have much luck with those... this seems to handle all enemy hits/grabs I tested fine though)

These patches are also tied in with the debug flags used by the game too, eg. invincibility can be enabled with the DBG_PL_NOHIT flag (sounded like the most appropriate for it)

E: also added a "weak enemies" patch that should let you kill most things in 1 hit, tied to DBG_EM_WEAK flag

Source: https://github.com/emoose/re4_tweaks/commit/31c72561e62b107926800726ba8537fdfba3bbe8

(updated) Build soon at https://github.com/emoose/re4_tweaks/actions/runs/2657900397

FutonGama commented 2 years ago

Try to make the INI for save the configuration, will be amazing. I tested alot and its working good.

linkthehylian commented 2 years ago

I never thought I'd see the day where disabling map collision would be an actual feature. I've wanted to explore a lot of the OoB parts of certain areas and now I can. 😄

I did have a possible suggestion too, could we potentially see an addition to spawn objects/characters/enemies? I think it could be really fun to mess around with all of that, imo.

Seriously, thank you for implementing this. Because the trainer I was using for this game is very outdated lmao.