Results 1 to 4 of 4

Thread: Move the campaign camera to a character with script

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Move the campaign camera to a character with script

    This script makes the campaign map camera jump to the location of a specific character. NOTE: it only works for the player's faction, not AI characters.

    Background
    With script we can test that he exists and select him but camera positions require x,y coordinates. So to point the camera at him would first require that we find out what those coordinates are (tricky if not impossible) and then a massive script containing one snap_strat_camera for every tile on the map, each wrapped in an IF statement such that the one that is executed is the one that matches his tile. This tutorial does it another way...

    This script uses the zoom button on the character's detail scroll. All it needs is the name of the character - "Boromir" in this example...

    Code:
    call_object_shortcut strat_ui capital_zoom
    select_ui_element construction_button
    simulate_mouse_click lclick_up
    
    select_character Boromir
    select_ui_element garrison_info_zoom_to_button
    simulate_mouse_click lclick_up
    
    hide_ui
    show_ui
    I couldn't figure out how to show the character scroll directly. So it first shows a settlement scroll which, after selecting the character, switches to showing the character scroll. Then it auto-clicks that scroll's zoom button. Finally it closes the scroll by hiding and reshowing the UI (I couldn't figure out how to close a scroll either).

    To show the settlement scroll it selects the faction capital and then auto-clicks the Construction button. I guess that other scrolls could work here but I didn't try it.

    garrison_info_zoom_to_button - not a typo. For some reason (bug?) this works but character_info_zoom_to_button does not.

    This method works wherever the character is:
    1. commanding an army
    2. in an army commanded by someone else
    3. in a settlement
    4. in a fort
    5. on a ship

    Only in situation 1) will he be 'physically' selected, i.e. his character icon highlighted and his movement range displayed. For example...

    Attachment 245923

    ...the left is the outcome of this script, the right is how it would be if I had manually selected him.

    Also, the camera will not be centered on his location, it will be to the right of him. This is because the zoom button puts him in the center of the left half of the screen, the right half being taken up by the scroll. As shown here...

    Attachment 245927

    Naturally the duplicate name problem still applies. If there are two Boromirs in the player's faction then this script might be zooming to the wrong one.
    Last edited by Withwnar; November 24, 2012 at 02:16 AM.

  2. #2
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Move the campaign camera to a character with script

    The result looks similar to missions that involve a character. Couldn't that be used as well? If you use the assassinate mission for the players faction with the character as target (would that trigger?) and then put the duration to 1000 rounds. then you could 'call him up' any time - with your own message and pic.

    script
    Code:
    create_mission [mission name] [faction that gets mission] [target character name]
    descr_mission
    Code:
    mission  assassinate_general [mission name]
    {
        COUNCIL_MISSION
        duration 1000
        event_mission
        paybacks
        {
             payback_id [payback name]
        }
        expire_on_hide_disabled ; prevents disabling of mission if character hides
    }
    Last edited by Gigantus; October 13, 2012 at 04:17 AM.










  3. #3
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Move the campaign camera to a character with script

    Ah, for zooming to an AI character. I have never dabbled with missions so I couldn't say. Would this mean that the mission remains in the Missions scroll from then on? I can't see anything like a cancel_mission command.

  4. #4
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Move the campaign camera to a character with script

    It's the 'duration' number that sets the length of the mission - that's how long the mission stays. I assume that the death of the character, regardless how, will cancel the mission.










Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •