Results 1 to 9 of 9

Thread: Stupid question: What is onTickGame

  1. #1
    Supporting Member
    Join Date
    Dec 2019
    Posts
    207
    Post Thanks / Like
    Total Downloaded
    11.46 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
    Team Fusion ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    611
    Post Thanks / Like
    Total Downloaded
    704.46 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
    207
    Post Thanks / Like
    Total Downloaded
    11.46 MB

    Re: Stupid question: What is onTickGame

    Ah interesting, thanks.

    I am Yo-Yo not YoYo (that's someone else)

  5. #4
    Supporting Member varrattu's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    391
    Post Thanks / Like
    Total Downloaded
    272.33 MB

    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 });
    		}
    	}
    }
    "... errors creep in with any game like this. When they are discovered, they are fixed." (RAF74_Buzzsaw, 2020-08-11)

  6. Likes Yo-Yo liked this post
  7. #5
    Supporting Member varrattu's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    391
    Post Thanks / Like
    Total Downloaded
    272.33 MB

    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()
                                );
                        }
                    }
                }           
                
            }     
        }
    
    }
    "... errors creep in with any game like this. When they are discovered, they are fixed." (RAF74_Buzzsaw, 2020-08-11)

  8. Likes Yo-Yo liked this post
  9. #6
    Supporting Member
    Join Date
    Dec 2019
    Posts
    207
    Post Thanks / Like
    Total Downloaded
    11.46 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
    Supporting Member varrattu's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    391
    Post Thanks / Like
    Total Downloaded
    272.33 MB

    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.
    "... errors creep in with any game like this. When they are discovered, they are fixed." (RAF74_Buzzsaw, 2020-08-11)

  11. #8
    Supporting Member
    Join Date
    Dec 2019
    Posts
    207
    Post Thanks / Like
    Total Downloaded
    11.46 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
    Supporting Member varrattu's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    391
    Post Thanks / Like
    Total Downloaded
    272.33 MB

    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.
    "... errors creep in with any game like this. When they are discovered, they are fixed." (RAF74_Buzzsaw, 2020-08-11)

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
  •