Ticket #1192: public.diff
File public.diff, 10.0 KB (added by , 12 years ago) |
---|
-
art/actors/fauna/deer.xml
7 7 <animation file="quadraped/deer_idle_01.dae" name="idle" speed="20"/> 8 8 <animation file="quadraped/deer_idle_02.dae" name="idle" speed="20"/> 9 9 <animation file="quadraped/deer_idle_03.dae" name="idle" speed="20"/> 10 <animation file="quadraped/deer_idle_04.dae" name="feeding" speed="20"/> 10 11 <animation file="quadraped/deer_walk_01.dae" name="walk" speed="35"/> 12 <animation file="quadraped/deer_walk_02.dae" name="walk_feeding" speed="35"/> 11 13 <animation file="quadraped/deer_run_01.dae" name="run" speed="20"/> 12 14 <animation file="quadraped/deer_attack_01.dae" name="melee" speed="20"/> 13 15 </animations> … … 31 33 </variant> 32 34 </group> 33 35 <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>43 36 <variant frequency="100" name="Idle"/> 44 37 <variant name="death"> 45 38 <props> -
art/actors/fauna/gazelle.xml
7 7 <animation file="quadraped/deer_idle_01.dae" name="idle" speed="20"/> 8 8 <animation file="quadraped/deer_idle_02.dae" name="idle" speed="20"/> 9 9 <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"/> 11 11 <animation file="quadraped/deer_death_01.dae" name="death" speed="40"/> 12 12 <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"/> 14 14 <animation file="quadraped/deer_run_01.dae" name="run" speed="15"/> 15 15 <animation file="quadraped/deer_attack_01.dae" name="melee" speed="20"/> 16 16 </animations> … … 25 25 <animation file="quadraped/deer_idle_01.dae" name="idle" speed="5"/> 26 26 <animation file="quadraped/deer_idle_02.dae" name="idle" speed="5"/> 27 27 <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"/> 29 29 <animation file="quadraped/deer_death_02.dae" name="death" speed="40"/> 30 30 <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"/> 32 32 <animation file="quadraped/deer_run_01.dae" name="run" speed="15"/> 33 33 <animation file="quadraped/deer_attack_01.dae" name="melee" speed="20"/> 34 <animation name=""/>35 34 </animations> 36 35 <mesh>skeletal/deer_mesh.dae</mesh> 37 36 <texture>skeletal/animal_gazelle_02.dds</texture> -
simulation/components/UnitAI.js
39 39 "<element name='RoamTimeMax'>" + 40 40 "<ref name='positiveDecimal'/>" + 41 41 "</element>" + 42 "<optional>" + 43 "<element name='Feeds'>" + 44 "<data type='boolean'/>" + 45 "</element>" + 46 "</optional>" + 42 47 "<element name='FeedTimeMin'>" + 43 48 "<ref name='positiveDecimal'/>" + 44 49 "</element>" + … … 1279 1284 }, 1280 1285 1281 1286 "IDLE": { 1282 // (We need an IDLE state so that FinishOrder works)1283 1284 1287 "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)); 1288 1292 }, 1289 },1290 1293 1291 "CORPSE": { 1292 "enter": function() { 1293 this.StopMoving(); 1294 "leave": function() { 1295 this.StopTimer(); 1294 1296 }, 1295 1297 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 } 1304 1312 }, 1305 1313 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 } 1312 1325 }, 1313 1326 }, 1314 1327 … … 1349 1362 }, 1350 1363 1351 1364 "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 } 1353 1373 }, 1354 1374 1355 1375 "MoveCompleted": function() { … … 1357 1377 }, 1358 1378 }, 1359 1379 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 1360 1404 "FEEDING": { 1361 1405 "enter": function() { 1406 if (!this.template.Feeds) 1407 this.StartTimer(0); 1408 1362 1409 // Stop and eat for a while 1363 1410 this.SelectAnimation("feeding"); 1364 1411 this.StopMoving(); … … 1388 1435 "MoveCompleted": function() { }, 1389 1436 1390 1437 "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 } 1392 1446 }, 1393 1447 }, 1394 1448 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 1395 1504 "FLEEING": "INDIVIDUAL.FLEEING", // reuse the same fleeing behaviour for animals 1396 1505 1397 1506 "COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals -
simulation/templates/gaia/fauna_deer.xml
13 13 <RangeMin>5.0</RangeMin> 14 14 </Run> 15 15 </UnitMotion> 16 <UnitAI> 17 <Feeds>true</Feeds> 18 </UnitAI> 16 19 <VisualActor> 17 20 <Actor>fauna/deer.xml</Actor> 18 21 </VisualActor> -
simulation/templates/gaia/fauna_gazelle.xml
11 11 <RangeMin>5.0</RangeMin> 12 12 </Run> 13 13 </UnitMotion> 14 <UnitAI> 15 <Feeds>true</Feeds> 16 </UnitAI> 14 17 <VisualActor> 15 18 <Actor>fauna/gazelle.xml</Actor> 16 19 </VisualActor>