View Single Post
  #25  
Old 10-16-2011, 04:38 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Quote:
Originally Posted by David198502 View Post
i tried the script with the planecounter command.but when i fly the mission, the second group spawns after i shot down only one plane...it will spawn a new group everytime i shoot a single plane.
Yes the script is not complete , there are two problems unsolved in it, i always hope the "students" find the problems and eliminate them.
"I've a dream"

OK what are the Problems.
The first, not only the plane itself has a name which contains "BoB_RAF_F_FatCat_Early", the pilot (and gunners) also contains it.
We need something that checked if it is a plane. For this we need a if-clause that check: if (actor is AiAircraft) so we only get the plane. If we want examine the crew extra we could use: if (actor is AiPerson)
So now we only get the plane, but an other problem still exist.
i use the if - clause:
if (planecounter >= 2)
but whats the problem, with this if-clause the planes spawn after shooting down two, but also after three , four ....
so it should changed in
if (planecounter == 2)

so the script should now look like:
Code:
using System;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;


public class Mission : AMission
{
    int planecounter = 0;

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

        AiAction MakeNewAircraft = GamePlay.gpGetAction("SpawnAircraft");

        if (actor != null && MakeNewAircraft != null && actor is AiAircraft)
        {
            if (actor.Name().Contains("BoB_RAF_F_FatCat_Early"))
            {
                planecounter++;

                if (planecounter == 2)
                {
                    MakeNewAircraft.Do();
                    GamePlay.gpHUDLogCenter("New Enemy spawned!");
                }
            }
        }
    }
}
Reply With Quote