Results 1 to 15 of 15

Thread: Define an actor?

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

    Define an actor?

    I have the following code showing a message when I die, I'm assuming it shows the message when any 'actor' dies, and that an 'actor' is an individual non-static object, so not a whole flight but either me, or one AI aircraft, ship, tank etc...

    If I am correct in this idea, I figure I can put in an: 'if' that says somethign like : if actor = "" { ..then do stuff...}

    but what do I use to recognise the different actors? Or please, correct my misunderstanding of an actor!

    using System;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    using System.Threading;

    public class Mission : AMission
    {


    public override void OnBattleStarted()
    {
    GamePlay.gpHUDLogCenter("Start");
    }

    public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
    {
    base.OnActorDead(missionNumber, shortName, actor, damages);

    GamePlay.gpHUDLogCenter("Something is dead");
    }


    }

    Thanks for any help.
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    I've found this code (inital variables part not showing) and i can see from this how it is using the on ActorDead to track squadron losses, allied squadron losses, lost bombers (defined by army) and then I get a little fuzzy on the 'win' stuff. Bot what I woudl like to know is how to have an onActorDead when that is the player? Is it somethign to do with that shortName.IndexOf ?

    :

    public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> initiatorList)
    {
    //Gabu

    if (actor is AiAircraft)
    {
    if (shortName.IndexOf("607Sqn", 0) > 0) MySquad++;// indicate own Sqn loss
    if (shortName.IndexOf("111Sqn", 0) > 0) Squad++;// indicates 111 sqn losses
    if( Squad > 3) // 111sqn more than 4 ac shot down ac
    {
    end = false;
    Campaign.battleSuccess = false;
    GamePlay.gpHUDLogCenter("FAIL");
    }
    if (actor.Army() == 2)
    {
    cEnemy++;
    //GamePlay.gpHUDLogCenter(shortName);
    if (shortName.IndexOf("ZG26", 0) > 0) hunt++;
    }

    else bomb++;

    if (actor.Army() == 1)
    {
    cFriendly++;
    GamePlay.gpHUDLogCenter("British down");
    }

    if (actor.Army() == 2)
    {
    if (GamePlay.gpPlayer().Place() != null)
    {
    bool playerWin = false;
    foreach (DamagerScore i in initiatorList)
    {
    if (i.initiator != null && i.initiator.Actor == GamePlay.gpPlayer().Place())
    {
    playerWin = true;
    }
    }
    if (playerWin) cPlayer++;

    }
    }
    //
    Timeout(5.0, () =>
    {
    ShowResult(true);
    });//for testing
    //Gabu end

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

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

    Re: Define an actor?

    I may be nearly there, I just was able to display the shortnames of things I shot down in a LogCenter display so will try to designate them in ifs based on that...
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    Check this.

    Code:
    using maddox.game;
    using maddox.game.world;
    using part;
    using System;
    using System.IO;
    using System.Collections.Generic;
    
    using maddox.GP;
    
    
    public class Mission : AMission {
    
    
    	private string SEPARATOR = " ";  //  NOT a space char
    
    
    	public override void OnBattleStarted()
    	{
    		GamePlay.gpLogServer(null, "OnBattleStarted", new object[] { });
    	}
    
    	
    	public override void OnBuildingKilled(string title, Point3d pos, AiDamageInitiator initiator, int eventArgInt) 
    	{
    		string[] parts = title.Split(new string[] { SEPARATOR }, StringSplitOptions.None);
    		GamePlay.gpLogServer(null, "Building Destroyed " + parts[2], new object[] { });
    	}
    
    
    	public override void OnStationaryKilled(int intWhat0, GroundStationary stationary, AiDamageInitiator initiator, int intWhat1) 
    	{
    		string[] parts = stationary.Title.Split(new string[] { SEPARATOR }, StringSplitOptions.None);
    		GamePlay.gpLogServer(null, "Stationary Destroyed " + parts[2], new object[] { });
    	}
    
    
    	public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages) 
    	{
    
    		if (actor is AiAircraft) { 
    			GamePlay.gpLogServer(null, "Aircraft Destroyed " + shortName + " " + actor.Name(), new object[] { });
    			return;
    		}
    		if (actor is AiGroundActor) { 
    			AiGroundActor groundActor = actor as AiGroundActor;
    			if (typeString.Contains("Ship")) {
    				GamePlay.gpLogServer(null, "Ship Destroyed " + shortName + " " + actor.Name(), new object[] { });
    			} else {
    				GamePlay.gpLogServer(null, "Ground Vehicle Destroyed " + shortName + " " + actor.Name(), new object[] { });
    			}
    		}
    	}
    }

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

    Re: Define an actor?

    Thanks, appreciated. Will take a look.
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    Hmm, no you've lost me there unforutnately, even the starting bit about the system.IO and then the separator that is not a space character had me flumoxed... no idea on what that is all about currently wiht my limited knowledge.

    I'll keep trying though!
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    OK, I have been looking at the all method list and it seems, anything that is 'Aircraft' means the player's aircraft, is that correct?

    I could show a test message when I took off using onAircraftTookOff and similarly a message when I broke my aircraft using onAircraftDamage.

    So, the methods that are Actor are they simply for use with anything else?

    e.g. Say I want to show a message when a certain aircraft in a flgiht is destroyed I use

    public override void OnActorDestroyed(int missionNumber, string shortName, maddox.game.world.AiActor actor)

    but put an 'if' in it for whether the shortName is == the actual single aircraft I mean. Does this make sense, is there an easier way?
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    I'm still struggling to understand what an 'actor' exacltly is, and also AiAircraft when I see that, does that mean AI, so nonplayer aircraft?
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    An Actor is anything that moves. Aircraft, vehicles, ships, etc. Also stationary objects with moving parts, AA guns, searchlights, etc.

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

    Re: Define an actor?

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

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

    Re: Define an actor?

    Please does that include the player?

    How is the player distinguished from AI?

    I can see all these methods for when damaged dead etc. what is the way to dertermine if it is the player, or an AI aircraft please?
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    Ok so here is something I've put together that seems to do what I mean, (if I get damaged it pops up a message that says "Bugger", if any other aircraft is damaged it says "Ouch", but do I have to do the "BoB_RAF_F_FatCat_Early.300" everytime, is there not a way I can simply do an "if player" kind of thing instead?

    Code:
    using System;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    
    public class Mission : AMission
    {
    
        public override void OnBattleStarted()
        {
            GamePlay.gpHUDLogCenter("Mission started");
           
        }
    
        public override void OnAircraftDamaged(int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft, maddox.game.world.AiDamageInitiator initiator, part.NamedDamageTypes damageType)
        {
            if (shortName.Equals ("BoB_RAF_F_FatCat_Early.300"))
    
                    {
                GamePlay.gpHUDLogCenter("Bugger!");
            }
            else
            {
                GamePlay.gpHUDLogCenter("Ouch!");
            }
    
            }
        }
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    Are you using Visual Studio as your development environment?

    Do you have a Solution with the dependency list below?

    Use intellisense to see the properties and functions of any object. https://code.visualstudio.com/docs/editor/intellisense

    Campaign.dll
    core.dll
    gamePlay.dll
    gameWorld.dll
    maddox.dll
    part.dll

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

    Re: Define an actor?

    OK, I'll stop with the questions sorry.
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Define an actor?

    I think with that tool you will be able to answer many of your questions. And read code from other missions, like the three I mentioned.

    But you can always ask questions.

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
  •