Author Topic: [Code] Perfectly Smooth, Mouse-Enabled Deathcam V1.4  (Read 15906 times)

0 Members and 1 Guest are viewing this topic.

Zephilinox

  • Knight
  • *
  • Perisno Developer
    • Skype - Zephilinox
    • Steam - 01111010
    • Twitter - Zephilinox
    • Twitch.tv - Zephilinox
    • YouTube - Zephilinox
    • View Profile
  • Faction: Swadian
  • WB
[Code] Perfectly Smooth, Mouse-Enabled Deathcam V1.4
« on: August 06, 2013, 10:45:10 PM »
Video of V1.0


Tested for Warband 1.157, Warband 1.158, Warband 1.167, and Diplomacy 4.2 (view page 2 for details on diplomacy integration)

Please note that the smoothness is dependent on frame-rate. The higher your frame-rate the smoother the camera rotation will be.

Features:
  • Smooth Mouse Rotation
  • Smooth Numpad Rotation
  • Move in 3 Dimensions
  • Works in Windowed Mode
  • Movement Speed Multiplier key
  • Sensitivity Modifier Key
  • Invert Y Rotation Key
  • Reset Deathcam to Position of Death
  • Works with Battle Orders (Backspace) Presentation

Used in:

Changelog:
Version 1.4
  • Added: Press 'End' to flip Y rotation
  • Added: Use numpad to rotate the camera in addition to the mouse (useful when having the battle presentation open, or if you can't rotate with the mouse for some reason)
  • Fixed: Now detects what team the player is on and only causes that team to charge
Version 1.3
  • Added: Press 'Home' to reset cameras position to where you died
  • Fixed: Now entering a presentation and exiting will not cause the camera to rotate
  • Fixed: Clamped rotation speed to reduce wild rotations when other, non-native presentations may be open
Version 1.2
  • Fixed: Now after losing, press TAB to end the battle
  • Fixed: Now after deathcam starts, pressing TAB will not mention being surrounded by enemies
  • Fixed: Now using display_message instead of display_log_message (smaller savegame)
  • Fixed: Exit rotation code if resetting mouse_notmoved
  • Removed: Deadzone/Padding, unlikely to ever be used
Version 1.1
  • Added: Numpad +/- to increase/decrease sensitivity
  • Fixed: Now deathcam doesn't rotate while battle order presentation is open

Keep in mind the code uses a fixed point of 10,000 rather than the usual 1,000.



Place the following code at the top of module_mission_templates.py

(click to show/hide)

(click to show/hide)



Replace common_battle_tab_press

(click to show/hide)

With:

(click to show/hide)



Replace any/all of these blocks of code for the relevant mission types (e.g lead_charge)

(click to show/hide)

With:

(click to show/hide)



Replace common_siege_check_defeat_condition

(click to show/hide)

With:

(click to show/hide)



Replace common_battle_check_victory_condition

(click to show/hide)

With:

(click to show/hide)



Finally, at the very top of each mission type you want the deathcam to be used (search for "common_battle_mission_start" as most relevant missions will use that too),  place these four lines:

(click to show/hide)

Like this:

(click to show/hide)
« Last Edit: October 29, 2016, 03:16:24 PM by Zephilinox »

La Grandmaster

  • Sergeant Knight at Arms
  • *
    • View Profile
  • Faction: Nord
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #1 on: August 07, 2013, 03:22:07 PM »
It seems to work fairly well, the only thing I can say is that if the player is in a party on their own and they are defeated, when they press tab instead of counting it so that the player has lost the battle, the game counts it as a retreat and then the player is allowed to charge at the enemy again. I dont know if this will also affect larger battles, but it may do Im not sure?

Zephilinox

  • Knight
  • *
  • Perisno Developer
    • Skype - Zephilinox
    • Steam - 01111010
    • Twitter - Zephilinox
    • Twitch.tv - Zephilinox
    • YouTube - Zephilinox
    • View Profile
  • Faction: Swadian
  • WB
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #2 on: August 07, 2013, 03:55:02 PM »
It seems to work fairly well, the only thing I can say is that if the player is in a party on their own and they are defeated, when they press tab instead of counting it so that the player has lost the battle, the game counts it as a retreat and then the player is allowed to charge at the enemy again. I dont know if this will also affect larger battles, but it may do Im not sure?

Thanks, it would affect other battles too. I'll look in to it.

Edit:
Quick fix, haven't tested it outside of lead_charge, I believe there's a few other places that I need to modify for sieges, I'll update the main post when I have.

(click to show/hide)

(click to show/hide)

This also fixes the "Cannot retreat, enemies near by" message you get within 4 seconds of dieing when trying to leave the battle.
« Last Edit: August 07, 2013, 05:15:46 PM by Zephilinox »

Swyter

  • Grandmaster Knight
  • *
  • »Star Wars Conquest Dev Team Leader
    • View Profile
    • [my tiny homepage]
  • Faction: Swadian
  • MP nick: Sareth | Swyter
  • WBM&BWF&S
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #3 on: August 07, 2013, 08:45:36 PM »
Friendly advice: Since like a week ago Janus added the possibility of directly embedding YouTube videos.
This may come in handy to you, so the demo has more exposure. Seems like an easy way to gain interest, even from non-coders.

Nice enhancement, by the way.

Zephilinox

  • Knight
  • *
  • Perisno Developer
    • Skype - Zephilinox
    • Steam - 01111010
    • Twitter - Zephilinox
    • Twitch.tv - Zephilinox
    • YouTube - Zephilinox
    • View Profile
  • Faction: Swadian
  • WB
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #4 on: August 07, 2013, 08:50:15 PM »
Friendly advice: Since like a week ago Janus added the possibility of directly embedding YouTube videos.
This may come in handy to you, so the demo has more exposure. Seems like an easy way to gain interest, even from non-coders.

Nice enhancement, by the way.

Thanks, I'll include the video in the main post soon. Coming from you that's high praise :)

Mandible

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #5 on: August 08, 2013, 12:44:43 AM »
You're really zipping around there! I like it!

Lumos

  • Probably Not a Help Desk
  • Moderator
  • *
  • Mens INsana in corpore sano
    • Steam - lumosx
    • YouTube - LumosX
    • View Profile
  • Faction: Nord
  • WBWF&SNWM&BVC
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #6 on: August 08, 2013, 09:46:20 AM »
Yeah, you're the polar opposite of the newbie who asks questions all the time, posts two mod threads that have got plainly impossible concepts, and dies after two weeks (or less). :D
Keep up the good work.

Zephilinox

  • Knight
  • *
  • Perisno Developer
    • Skype - Zephilinox
    • Steam - 01111010
    • Twitter - Zephilinox
    • Twitch.tv - Zephilinox
    • YouTube - Zephilinox
    • View Profile
  • Faction: Swadian
  • WB
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #7 on: August 10, 2013, 03:22:37 PM »
Yeah, you're the polar opposite of the newbie who asks questions all the time, posts two mod threads that have got plainly impossible concepts, and dies after two weeks (or less). :D
Keep up the good work.

It always makes me cringe when I see those threads :P

Updated to V1.3. fixed the issue with crazy rotation when exiting a presentation and added a new key. Minimal testing done in Diplomacy 4.2, but works.

Michadr

  • Grandmaster Knight
  • *
  • Perisno Lead Developer
    • Steam - http://steamcommunity.com/id/michadr
    • Twitter - @realmichadr
    • Twitch.tv - http://www.twitch.tv/michadr/
    • YouTube - michaeldecker7
    • View Profile
    • Perisno
  • Faction: Nord
  • MP nick: Michadr
  • WBM&BVC
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #8 on: August 15, 2013, 06:33:41 PM »
This made my year (litterly)
It works just fine replacing the "hard" to use Diplomacy cam. (version 4.3)
Amazing work by the way, every mod should have this.

Thane Delphi

  • Guest
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #9 on: August 16, 2013, 05:21:44 AM »
Nicely done.

FALX

  • Master Knight
  • *
  • Wyrd bið ful aræd
    • View Profile
  • Faction: Bandit
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #10 on: August 17, 2013, 05:15:14 PM »
            (display_message,"str_can_not_retreat", color_neutral_news),

color_neutral_news    -   is not defined
                                                                            It`s with compilation errors .

Lumos

  • Probably Not a Help Desk
  • Moderator
  • *
  • Mens INsana in corpore sano
    • Steam - lumosx
    • YouTube - LumosX
    • View Profile
  • Faction: Nord
  • WBWF&SNWM&BVC
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #11 on: August 17, 2013, 06:43:57 PM »
Define it then. What color do you want your neutral news to be in? White seems neutral enough, right? Slap color_neutral_news = 0xFFFFFF in module_constants.

Zephilinox

  • Knight
  • *
  • Perisno Developer
    • Skype - Zephilinox
    • Steam - 01111010
    • Twitter - Zephilinox
    • Twitch.tv - Zephilinox
    • YouTube - Zephilinox
    • View Profile
  • Faction: Swadian
  • WB
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #12 on: August 17, 2013, 07:33:41 PM »
            (display_message,"str_can_not_retreat", color_neutral_news),

color_neutral_news    -   is not defined
                                                                            It`s with compilation errors .

Whoops, sorry, thought I had removed all of that. Delete ", color_neutral_news"

I'll fix it when I get back from camping.

FALX

  • Master Knight
  • *
  • Wyrd bið ful aræd
    • View Profile
  • Faction: Bandit
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #13 on: August 18, 2013, 09:12:50 PM »
Define it then. What color do you want your neutral news to be in? White seems neutral enough, right? Slap color_neutral_news = 0xFFFFFF in module_constants.
            (display_message,"str_can_not_retreat", color_neutral_news),

color_neutral_news    -   is not defined
                                                                            It`s with compilation errors .

Whoops, sorry, thought I had removed all of that. Delete ", color_neutral_news"

I'll fix it when I get back from camping.

Thanks for the hint. So it really looks better Slap color_neutral_news = 0xFFFFFF in module_constants.". :D

Lumos

  • Probably Not a Help Desk
  • Moderator
  • *
  • Mens INsana in corpore sano
    • Steam - lumosx
    • YouTube - LumosX
    • View Profile
  • Faction: Nord
  • WBWF&SNWM&BVC
Re: Perfectly Smooth, Mouse-Enabled Deathcam
« Reply #14 on: August 18, 2013, 10:51:05 PM »
Slapping it in the constants will allow you to use it for other messages and stuff like that. Besides, you can never have too many constants. Except when they lead to the same thing, that is. :)