Results 1 to 9 of 9

Thread: Stupid question: What is onTickGame

  1. #1
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Stupid question: What is onTickGame

    Just that, what is the tick of a game?

    Is it MP related for the battle ending or something completely different that applies to SP?
    I am Yo-Yo not YoYo (that's someone else)

  2. #2
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: Stupid question: What is onTickGame

    That OnTickGame is called about 33 times per second while the battle is running. If you are writing your own code you will often be calling it from there.

  3. Likes Yo-Yo liked this post
  4. #3
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: Stupid question: What is onTickGame

    Ah interesting, thanks.
    I am Yo-Yo not YoYo (that's someone else)

  5. #4
    varrattu
    Guest

    Re: Stupid question: What is onTickGame

    Enclosed please find a little example ...

    ~V~

    Code:
    using System;
    using maddox.game;
    using maddox.game.world;
    
    public class Mission : AMission
    {
    	public override void OnTickGame()
    	{
    		double ElapsedSeconds;
    
    		if (Time.tickCounter() == 334)
    		{
    			ElapsedSeconds = Time.TicksToSecs(Time.tickCounter());
    			GamePlay.gpLogServer(null, "{0} ticks are {1} seconds\n", new object[] { Time.tickCounter(), ElapsedSeconds });
    		}
    
    		if (Time.tickCounter() == 667)
    		{
    
    			ElapsedSeconds = Time.TicksToSecs(Time.tickCounter());
    			GamePlay.gpLogServer(null, "{0} ticks are {1} seconds\n", new object[] { Time.tickCounter(), ElapsedSeconds });
    		}
    
    		if (Time.tickCounter() == 1000)
    		{
    
    			ElapsedSeconds = Time.TicksToSecs(Time.tickCounter());
    			GamePlay.gpLogServer(null, "{0} ticks are {1} seconds\n", new object[] { Time.tickCounter(), ElapsedSeconds });
    		}
    	}
    }

  6. Likes Yo-Yo liked this post
  7. #5
    varrattu
    Guest

    Re: Stupid question: What is onTickGame

    Enclosed please find another example ...

    ~V~

    Code:
    using System;
    using maddox.game;
    using maddox.game.world;
    using maddox.GP;
    using System.Collections.Generic;
    
    
    public class Mission : AMission
    {
        private double nextMsgTime = 0;
    
        public override void OnTickGame()
        {
            {
                base.OnTickGame();
                
                if (Time.current() > nextMsgTime)
                {
                    nextMsgTime = Time.current() + 10.0; // 10 seconds to next message
                    
                    // Leave this in if you want to test a timer
                    //GamePlay.gpHUDLogCenter("Time elapsed (in seconds) = " + Time.current() + 
                    //    ", next message will be at " + nextMsgTime);
    
                    if (GamePlay.gpPlayer() != null) // check if we have a player.
                    {
                        if (GamePlay.gpPlayer().Place() != null)
                        {
                            Player me = GamePlay.gpPlayer();
                            AiActor where = me.Place();
                            Point3d pos = me.Place().Pos();
                            GamePlay.gpHUDLogCenter("Where? x:" +
                                    ((int)pos.x).ToString() + 
                                    "  y: " + 
                                    ((int)pos.y).ToString() + 
                                    "  z: " + 
                                    ((int)pos.z).ToString()
                                );
                        }
                    }
                }           
                
            }     
        }
    
    }

  8. Likes Yo-Yo liked this post
  9. #6
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: Stupid question: What is onTickGame

    Quote Originally Posted by varrattu View Post
    Enclosed please find another example ...

    ~V~

    Code:
    using System;
    using maddox.game;
    using maddox.game.world;
    using maddox.GP;
    using System.Collections.Generic;
    
    
    public class Mission : AMission
    {
        private double nextMsgTime = 0;
    
        public override void OnTickGame()
        {
            {
                base.OnTickGame();
                
                if (Time.current() > nextMsgTime)
                {
                    nextMsgTime = Time.current() + 10.0; // 10 seconds to next message
                    
                    // Leave this in if you want to test a timer
                    //GamePlay.gpHUDLogCenter("Time elapsed (in seconds) = " + Time.current() + 
                    //    ", next message will be at " + nextMsgTime);
    
                    if (GamePlay.gpPlayer() != null) // check if we have a player.
                    {
                        if (GamePlay.gpPlayer().Place() != null)
                        {
                            Player me = GamePlay.gpPlayer();
                            AiActor where = me.Place();
                            Point3d pos = me.Place().Pos();
                            GamePlay.gpHUDLogCenter("Where? x:" +
                                    ((int)pos.x).ToString() + 
                                    "  y: " + 
                                    ((int)pos.y).ToString() + 
                                    "  z: " + 
                                    ((int)pos.z).ToString()
                                );
                        }
                    }
                }           
                
            }     
        }
    
    }
    Thanks, this one in particular helps with something I was looking into.
    I am Yo-Yo not YoYo (that's someone else)

  10. #7
    varrattu
    Guest

    Re: Stupid question: What is onTickGame

    Is it secret?

    ~V~

    Quote Originally Posted by Yo-Yo View Post
    Thanks, this one in particular helps with something I was looking into.

  11. #8
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: Stupid question: What is onTickGame

    Quote Originally Posted by varrattu View Post
    Is it secret?

    ~V~
    No not particularly, I've just see so many bits of code and they peak my interest in different ways.

    Identifying the player and by the looks of it their 3d position seems interesting and useful to me thats all.
    I am Yo-Yo not YoYo (that's someone else)

  12. #9
    varrattu
    Guest

    Re: Stupid question: What is onTickGame

    Here you will find a bunch of inspiration and help ....

    Official 1C Company forum > FMB, Mission & Campaign builder Discussions

    FMB, Mission & Campaign builder Discussions > Scripts collection

    ~V~

    PS: while browsing around there you should be listening to Richard Strauss, Op.30
    Last edited by varrattu; Sep-16-2020 at 08:04.

  13. Likes fenbeiduo liked this post

Bookmarks

Posting Permissions

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