Ticket #1192: public.diff

File public.diff, 10.0 KB (added by Zaggy1024, 15 months ago)
  • art/actors/fauna/deer.xml

     
    77        <animation file="quadraped/deer_idle_01.dae" name="idle" speed="20"/> 
    88        <animation file="quadraped/deer_idle_02.dae" name="idle" speed="20"/> 
    99        <animation file="quadraped/deer_idle_03.dae" name="idle" speed="20"/> 
     10        <animation file="quadraped/deer_idle_04.dae" name="feeding" speed="20"/> 
    1011        <animation file="quadraped/deer_walk_01.dae" name="walk" speed="35"/> 
     12        <animation file="quadraped/deer_walk_02.dae" name="walk_feeding" speed="35"/> 
    1113        <animation file="quadraped/deer_run_01.dae" name="run" speed="20"/> 
    1214        <animation file="quadraped/deer_attack_01.dae" name="melee" speed="20"/> 
    1315      </animations> 
     
    3133    </variant> 
    3234  </group> 
    3335  <group> 
    34     <variant frequency="100" name="normal"/> 
    35     <variant frequency="0" name="feeding"> 
    36       <animations> 
    37         <animation file="quadraped/deer_idle_04.dae" name="idle" speed="20"/> 
    38         <animation file="quadraped/deer_walk_02.dae" name="walk" speed="20"/> 
    39       </animations> 
    40     </variant> 
    41   </group> 
    42   <group> 
    4336    <variant frequency="100" name="Idle"/> 
    4437    <variant name="death"> 
    4538      <props> 
  • art/actors/fauna/gazelle.xml

     
    77        <animation file="quadraped/deer_idle_01.dae" name="idle" speed="20"/> 
    88        <animation file="quadraped/deer_idle_02.dae" name="idle" speed="20"/> 
    99        <animation file="quadraped/deer_idle_03.dae" name="idle" speed="20"/> 
    10         <animation file="quadraped/deer_idle_04.dae" name="idle" speed="20"/> 
     10        <animation file="quadraped/deer_idle_04.dae" name="feeding" speed="20"/> 
    1111        <animation file="quadraped/deer_death_01.dae" name="death" speed="40"/> 
    1212        <animation file="quadraped/deer_walk_01.dae" name="walk" speed="20"/> 
    13         <animation file="quadraped/deer_walk_02.dae" name="walk" speed="20"/> 
     13        <animation file="quadraped/deer_walk_02.dae" name="walk_feeding" speed="20"/> 
    1414        <animation file="quadraped/deer_run_01.dae" name="run" speed="15"/> 
    1515        <animation file="quadraped/deer_attack_01.dae" name="melee" speed="20"/> 
    1616      </animations> 
     
    2525        <animation file="quadraped/deer_idle_01.dae" name="idle" speed="5"/> 
    2626        <animation file="quadraped/deer_idle_02.dae" name="idle" speed="5"/> 
    2727        <animation file="quadraped/deer_idle_03.dae" name="idle" speed="5"/> 
    28         <animation file="quadraped/deer_idle_04.dae" name="idle" speed="5"/> 
     28        <animation file="quadraped/deer_idle_04.dae" name="feeding" speed="5"/> 
    2929        <animation file="quadraped/deer_death_02.dae" name="death" speed="40"/> 
    3030        <animation file="quadraped/deer_walk_01.dae" name="walk" speed="20"/> 
    31         <animation file="quadraped/deer_walk_02.dae" name="walk" speed="20"/> 
     31        <animation file="quadraped/deer_walk_02.dae" name="walk_feeding" speed="20"/> 
    3232        <animation file="quadraped/deer_run_01.dae" name="run" speed="15"/> 
    3333        <animation file="quadraped/deer_attack_01.dae" name="melee" speed="20"/> 
    34         <animation name=""/> 
    3534      </animations> 
    3635      <mesh>skeletal/deer_mesh.dae</mesh> 
    3736      <texture>skeletal/animal_gazelle_02.dds</texture> 
  • simulation/components/UnitAI.js

     
    3939            "<element name='RoamTimeMax'>" + 
    4040                "<ref name='positiveDecimal'/>" + 
    4141            "</element>" + 
     42            "<optional>" + 
     43                "<element name='Feeds'>" + 
     44                    "<data type='boolean'/>" + 
     45                "</element>" + 
     46            "</optional>" + 
    4247            "<element name='FeedTimeMin'>" + 
    4348                "<ref name='positiveDecimal'/>" + 
    4449            "</element>" + 
     
    12791284        }, 
    12801285 
    12811286        "IDLE": { 
    1282             // (We need an IDLE state so that FinishOrder works) 
    1283  
    12841287            "enter": function() { 
    1285                 // Start feeding immediately 
    1286                 this.SetNextState("FEEDING"); 
    1287                 return true; 
     1288                // Stop and stand for a while 
     1289                this.SelectAnimation("idle"); 
     1290                this.StopMoving(); 
     1291                this.StartTimer(RandomInt(+this.template.FeedTimeMin, +this.template.FeedTimeMax)); 
    12881292            }, 
    1289         }, 
    12901293 
    1291         "CORPSE": { 
    1292             "enter": function() { 
    1293                 this.StopMoving(); 
     1294            "leave": function() { 
     1295                this.StopTimer(); 
    12941296            }, 
    12951297 
    1296             // Ignore all orders that animals might otherwise respond to 
    1297             "Order.FormationWalk": function() { }, 
    1298             "Order.Walk": function() { }, 
    1299             "Order.WalkToTarget": function() { }, 
    1300             "Order.Attack": function() { }, 
    1301  
    1302             "Attacked": function(msg) { 
    1303                 // Do nothing, because we're dead already 
     1298            "LosRangeUpdate": function(msg) { 
     1299                if (this.template.NaturalBehaviour == "skittish") 
     1300                { 
     1301                    if (msg.data.added.length > 0) 
     1302                    { 
     1303                        this.Flee(msg.data.added[0], false); 
     1304                        return; 
     1305                    } 
     1306                } 
     1307                // Start attacking one of the newly-seen enemy (if any) 
     1308                else if (this.template.NaturalBehaviour == "violent") 
     1309                { 
     1310                    this.AttackVisibleEntity(msg.data.added); 
     1311                } 
    13041312            }, 
    13051313 
    1306             "Order.LeaveFoundation": function(msg) { 
    1307                 // We can't walk away from the foundation (since we're dead), 
    1308                 // but we mustn't block its construction (since the builders would get stuck), 
    1309                 // and we don't want to trick gatherers into trying to reach us when 
    1310                 // we're stuck in the middle of a building, so just delete our corpse. 
    1311                 Engine.DestroyEntity(this.entity); 
     1314            "MoveCompleted": function() { }, 
     1315 
     1316            "Timer": function(msg) { 
     1317                if (RandomInt(0, 2) == 0 && this.template.Feeds) 
     1318                { 
     1319                    this.SetNextState("FEEDING"); 
     1320                } 
     1321                else 
     1322                { 
     1323                    this.SetNextState("ROAMING"); 
     1324                } 
    13121325            }, 
    13131326        }, 
    13141327 
     
    13491362            }, 
    13501363 
    13511364            "Timer": function(msg) { 
    1352                 this.SetNextState("FEEDING"); 
     1365                if (RandomInt(0, 2) == 0 && this.template.Feeds) 
     1366                { 
     1367                    this.SetNextState("FEEDING"); 
     1368                } 
     1369                else 
     1370                { 
     1371                    this.SetNextState("IDLE"); 
     1372                } 
    13531373            }, 
    13541374 
    13551375            "MoveCompleted": function() { 
     
    13571377            }, 
    13581378        }, 
    13591379 
     1380        "CORPSE": { 
     1381            "enter": function() { 
     1382                this.StopMoving(); 
     1383            }, 
     1384 
     1385            // Ignore all orders that animals might otherwise respond to 
     1386            "Order.FormationWalk": function() { }, 
     1387            "Order.Walk": function() { }, 
     1388            "Order.WalkToTarget": function() { }, 
     1389            "Order.Attack": function() { }, 
     1390 
     1391            "Attacked": function(msg) { 
     1392                // Do nothing, because we're dead already 
     1393            }, 
     1394 
     1395            "Order.LeaveFoundation": function(msg) { 
     1396                // We can't walk away from the foundation (since we're dead), 
     1397                // but we mustn't block its construction (since the builders would get stuck), 
     1398                // and we don't want to trick gatherers into trying to reach us when 
     1399                // we're stuck in the middle of a building, so just delete our corpse. 
     1400                Engine.DestroyEntity(this.entity); 
     1401            }, 
     1402        }, 
     1403 
    13601404        "FEEDING": { 
    13611405            "enter": function() { 
     1406                if (!this.template.Feeds) 
     1407                    this.StartTimer(0); 
     1408 
    13621409                // Stop and eat for a while 
    13631410                this.SelectAnimation("feeding"); 
    13641411                this.StopMoving(); 
     
    13881435            "MoveCompleted": function() { }, 
    13891436 
    13901437            "Timer": function(msg) { 
    1391                 this.SetNextState("ROAMING"); 
     1438                if (RandomInt(0, 2) == 0 && this.template.Feeds) 
     1439                { 
     1440                    this.SetNextState("ROAMINGFEEDING"); 
     1441                } 
     1442                else 
     1443                { 
     1444                    this.SetNextState("IDLE"); 
     1445                } 
    13921446            }, 
    13931447        }, 
    13941448 
     1449        "ROAMINGFEEDING": { 
     1450            "enter": function() { 
     1451                if (!this.template.Feeds) 
     1452                    this.StartTimer(0); 
     1453 
     1454                // Walk in a random direction 
     1455                this.SelectAnimation("walk_feeding", false, this.GetWalkSpeed()); 
     1456                this.MoveRandomly(+this.template.RoamDistance); 
     1457                // Set a random timer to switch to feeding state 
     1458                this.StartTimer(RandomInt(+this.template.RoamTimeMin, +this.template.RoamTimeMax)); 
     1459            }, 
     1460 
     1461            "leave": function() { 
     1462                this.StopTimer(); 
     1463            }, 
     1464 
     1465            "LosRangeUpdate": function(msg) { 
     1466                if (this.template.NaturalBehaviour == "skittish") 
     1467                { 
     1468                    if (msg.data.added.length > 0) 
     1469                    { 
     1470                        this.Flee(msg.data.added[0], false); 
     1471                        return; 
     1472                    } 
     1473                } 
     1474                // Start attacking one of the newly-seen enemy (if any) 
     1475                else if (this.template.NaturalBehaviour == "violent" || 
     1476                         this.template.NaturalBehaviour == "aggressive") 
     1477                { 
     1478                    this.AttackVisibleEntity(msg.data.added); 
     1479                } 
     1480 
     1481                // TODO: if two units enter our range together, we'll attack the 
     1482                // first and then the second won't trigger another LosRangeUpdate 
     1483                // so we won't notice it. Probably we should do something with 
     1484                // ResetActiveQuery in ROAMING.enter/FEEDING.enter in order to 
     1485                // find any units that are already in range. 
     1486            }, 
     1487 
     1488            "Timer": function(msg) { 
     1489                if (RandomInt(0, 2) == 0 && this.template.Feeds) 
     1490                { 
     1491                    this.SetNextState("FEEDING"); 
     1492                } 
     1493                else 
     1494                { 
     1495                    this.SetNextState("IDLE"); 
     1496                } 
     1497            }, 
     1498 
     1499            "MoveCompleted": function() { 
     1500                this.MoveRandomly(+this.template.RoamDistance); 
     1501            }, 
     1502        }, 
     1503 
    13951504        "FLEEING": "INDIVIDUAL.FLEEING", // reuse the same fleeing behaviour for animals 
    13961505 
    13971506        "COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals 
  • simulation/templates/gaia/fauna_deer.xml

     
    1313      <RangeMin>5.0</RangeMin> 
    1414    </Run> 
    1515  </UnitMotion> 
     16  <UnitAI> 
     17    <Feeds>true</Feeds> 
     18  </UnitAI> 
    1619  <VisualActor> 
    1720    <Actor>fauna/deer.xml</Actor> 
    1821  </VisualActor> 
  • simulation/templates/gaia/fauna_gazelle.xml

     
    1111      <RangeMin>5.0</RangeMin> 
    1212    </Run> 
    1313  </UnitMotion> 
     14  <UnitAI> 
     15    <Feeds>true</Feeds> 
     16  </UnitAI> 
    1417  <VisualActor> 
    1518    <Actor>fauna/gazelle.xml</Actor> 
    1619  </VisualActor>