Scenario Edition made easy

When you need to set up a scenario and precisely define the behavior of each participant, you need a tool that allows such freedom. Most of the tools on the market provide predefined tasks and doctrines that cannot be changed. It can be very sexy with stunning 3D output but beyond the game aspect you won’t get what you needed.

With vsTASKER, you have the ability to build your scenario the way you want. You define graphically your own doctrines based on state-machine like logics. You attach behaviors and sensors to your entities. You populate the gaming area. You specify what to do upon communications, detections, signals, whatever events which occur during the simulation and you quickly get a realistic virtual battlefield up an running.

Taiwan Strait

Ships

Three fleets of ships are defined. Two for the red force and one for the white. In the white fleet, only one ship (Kunming) has a logic, a radar and a sonar.

Kunming frigate logic

The two most important items of this logic are Send_UAV and Send2Pos which directs the drone to the computed position. Send_UAV consider an area and not individual detections.

Send_UAV code
Array<Vt_Entity>* list = (Array<Vt_Entity>*) edata();

if (vt_rtc->getCurrentTime() < 15) return RESTART; // radar warmup

if (list) { // in case of detection
   for (int i=0; i<list->count(); i++) { // for each of them
      Vt_Entity* dtc = list->get(i);
      float dist = ent()->pos.distanceTo2D(dtc->pos);
      if (dtc->getStatus()->isCategory(_Surface)) { // only for detected vessels
         if (logk()->trySendDroneTo(dtc, dist)) {
            printf("%s send drone to %s\n", ent()->getName(), dtc->getName());
            vt_rtc->gui_map.drawLine(ent()->pos, dtc->pos, clRed, 1);
            break;
         }
      }
   }
}

int Maritime_Blue_Lgk::trySendDroneTo(Vt_Entity* dtc, float d)
{
   // determine the position according to the speed and
   // heading of the target, considering the time for the
   // UAV to get there, at 800 km/h
   float dt = d / convert(800, _km_h, _m_s);
   float tdist = dt * dtc->getSpeed() * 2;

   WCoord* new_area = new WCoord(dtc->pos.getNewPosAt(dtc->getHeading(), 0, tdist));

   for (int i=0; i<checked_areas.count(); i++) {
       WCoord* pos = checked_areas[i];
       if (pos->distanceTo2D(*new_area) < region_size*1000) {
          delete new_area;
          return 0; // already checked
       }
   }
   // let's add the zone
   checked_areas.addElem(new_area);

   // let's create a drone
   new_UAV = new Entity("UAV_Blue", ent()->pos, "GJ-11-1");
   if (new_UAV->isValid()) {
      new_UAV->getDyn()->resetHeading(ent()->getHeading());
      new_UAV->owner = ent();
      new_UAV->area = new_area;  // where to go
      return 1;
   }
   else new_UAV = NULL;
   return 0;
}

Jet fighters

White and red jet fighters are created by air force bases upon reception of a threat by Kunming frigate (for white forces) or Yaoshan radar. All airports share the same logic.
White jets have their prime mission to destroyed a given red ship. The red jets have for mission to fight and kill a specific white jet. Dogfight will be triggered when both are in visual range.

White jet fighter logic
Close Enough Attack code
  MultiBarrel* mb = E:findMultiBarrel();
  BasicMissile* homing = (BasicMissile*) mb->fire("KD10_1");
  if (homing ) { // got one
     homing->guide(this->entity, E:target);
     E:target = NULL; // done
  }
Visual Attack code
  Array<Vt_Entity>* dlist = (Array<Vt_Entity>*)edata();
  // if the target is detected, let's shoot it
  if (dlist->exist(logk()->attacker)) {
     // compute the bearing angle with the target
     float b = fabs(ent()->getDyn()->getBearingTo(logk()->attacker->pos));
     // if target in a 5° window, roll a dice: 1,2,3,4 = miss; 5,6 = hit
     if (R2D(b) < 5 && DICE() > 4) { // target hit
        logk()->attacker->getStatus()->setWreck();
        return DONE;
     }
  }
  else return RESTART;

Drones

UAV are sent by white frigate Kunming upon detection of red vessels on an area not covered by another UAV. Once launched, the drone will head towards the area and start randomly patrolling over the region. Whatever is detected by its sensor is forwarded to ship Kunming. As soon as fuel is low, the drone will return to its ship.

Drone main logic

Surveillance Radar

One radar has been put at the top of a mountain range, to cover the strait without shadow. The Yaoshan logic is fairly simple:

  • Record: extract from all detections any new valid threats
  • CallAF: select air bases and forward all new threats
Radar logic

Submarines

Two submarines are stationned on coastal harbors and can receive the AttackBlue event from Yaoshan radar (see image above). When requested, they will navigate in the strait and rely on their sonar to detect enemy ships. Use of torpedoes to destroy targeted ships.

Submarine logic
Visual Attack code
  Array<Vt_Entity>* dlist = (Array<Vt_Entity>*)edata();
  Vt_Entity* e = dlist->getRandom();

  // if the target is detected, let's shoot it
  if (!L:targeted.hasElem(e) &&
      !e->getStatus()->isWreck())
  {
     E:setHeading(e->pos);
     float d = E:pos.distanceTo2D(e->pos);
     if (d < 5000) { // km
        MultiBarrel* mb = E:findMultiBarrel();
        Torpedo* homing = (Torpedo*) mb->fire("MK48_1");
        homing->guide(this->entity, e);
        L:targeted.addElem(e);
     }
  }