Changeset 233 for experiments/frams/deathmatch/data/scripts
- Timestamp:
- 04/29/14 18:26:49 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experiments/frams/deathmatch/data/scripts/deathmatch.expdef
r231 r233 26 26 initPopulations(); 27 27 28 Shapes.set("1p_weaponbox"," //0\n"+29 "p:-0.5, -0.5, -0.5\n"+ 30 "p: 0.5, -0.5, -0.5\n"+ 31 "p: 0.5, 0.5, -0.5\n"+ 32 "p: -0.5, 0.5, -0.5\n"+ 33 "p:-0.5, -0.5, 0.5\n"+ 34 "p:0.5, -0.5, 0.5\n"+ 35 "p:0.5, 0.5, 0.5\n"+ 36 "p:-0.5, 0.5, 0.5\n"+ 37 "j: 0,1\n"+ 38 "j: 1,2\n"+ 39 "j: 2,3\n"+ 40 "j: 3,0\n"+ 41 "j: 4,5\n"+ 42 "j: 5,6\n"+ 43 "j: 6,7\n"+ 44 "j: 7,4\n"+ 45 "j: 0,4\n"+ 46 "j: 1,5\n"+ 47 "j: 2,6\n"+ 48 "j: 3,7", 0x0FAA0F);49 50 Shapes.set("1p_hpbox"," //0\n"+51 "p:-0.5, -0.5, -0.5\n"+ 52 "p: 0.5, -0.5, -0.5\n"+ 53 "p: 0.5, 0.5, -0.5\n"+ 54 "p: -0.5, 0.5, -0.5\n"+ 55 "p:-0.5, -0.5, 0.5\n"+ 56 "p:0.5, -0.5, 0.5\n"+ 57 "p:0.5, 0.5, 0.5\n"+ 58 "p:-0.5, 0.5, 0.5\n"+ 59 "j: 0,1\n"+ 60 "j: 1,2\n"+ 61 "j: 2,3\n"+ 62 "j: 3,0\n"+ 63 "j: 4,5\n"+ 64 "j: 5,6\n"+ 65 "j: 6,7\n"+ 66 "j: 7,4\n"+ 67 "j: 0,4\n"+ 68 "j: 1,5\n"+ 69 "j: 2,6\n"+ 70 "j: 3,7", 0xAA0F0F);28 Shapes.set("1p_weaponbox","""//0 29 p:-0.5, -0.5, -0.5 30 p: 0.5, -0.5, -0.5 31 p: 0.5, 0.5, -0.5 32 p: -0.5, 0.5, -0.5 33 p:-0.5, -0.5, 0.5 34 p:0.5, -0.5, 0.5 35 p:0.5, 0.5, 0.5 36 p:-0.5, 0.5, 0.5 37 j: 0,1 38 j: 1,2 39 j: 2,3 40 j: 3,0 41 j: 4,5 42 j: 5,6 43 j: 6,7 44 j: 7,4 45 j: 0,4 46 j: 1,5 47 j: 2,6 48 j: 3,7""", 0x0FAA0F); 49 50 Shapes.set("1p_hpbox","""//0 51 p:-0.5, -0.5, -0.5 52 p: 0.5, -0.5, -0.5 53 p: 0.5, 0.5, -0.5 54 p: -0.5, 0.5, -0.5 55 p:-0.5, -0.5, 0.5 56 p:0.5, -0.5, 0.5 57 p:0.5, 0.5, 0.5 58 p:-0.5, 0.5, 0.5 59 j: 0,1 60 j: 1,2 61 j: 2,3 62 j: 3,0 63 j: 4,5 64 j: 5,6 65 j: 6,7 66 j: 7,4 67 j: 0,4 68 j: 1,5 69 j: 2,6 70 j: 3,7""", 0xAA0F0F); 71 71 } 72 72 … … 77 77 78 78 //add Food population (group 0) 79 Population.name = "Food"; 80 Population.nnsim = 0; 81 Population.enableperf = 0; 82 Population.death = 1; 83 Population.energy = 1; 84 Population.selfmask = 0x20002; 85 Population.othermask = 0x10002; 79 var p=Populations[0]; 80 p.name = "Food"; 81 p.nnsim = 0; 82 p.enableperf = 0; 83 p.death = 1; 84 p.energy = 1; 85 p.selfmask = 0x20002; 86 p.othermask = 0x10002; 86 87 87 88 //add Weapon Upgrade population (group 1) 88 Populations.addGroup("Upgrades");89 Population.nnsim = 0;90 Population.enableperf = 0;91 Population.death = 1;92 Population.energy = 1;93 Population.selfmask = 0x20002;94 Population.othermask = 0x10002;89 p=Populations.addGroup("Upgrades"); 90 p.nnsim = 0; 91 p.enableperf = 0; 92 p.death = 1; 93 p.energy = 1; 94 p.selfmask = 0x20002; 95 p.othermask = 0x10002; 95 96 96 97 //add Teams populations (group above 2) 97 98 var i = 0; 98 99 teams = ExpParams.teamCount; 99 if (teams == 1) { 100 GenePools.group = 0; 101 teams = GenePool.size; 102 } 100 if (teams == 1) 101 teams = GenePools[0].size; 103 102 for (i = 0; i < teams; i++) 104 103 { 105 Populations.addGroup("Team "+i);106 Population.nnsim = 1;107 Population.enableperf = 1;108 Population.death = 0;109 Population.energy = 1;110 Population.selfmask = 0x50001;111 Population.othermask = 0x60001;104 p=Populations.addGroup("Team "+i); 105 p.nnsim = 1; 106 p.enableperf = 1; 107 p.death = 0; 108 p.energy = 1; 109 p.selfmask = 0x50001; 110 p.othermask = 0x60001; 112 111 } 113 112 … … 127 126 function initCreatures() 128 127 { 129 var i = 0; 130 var j = 0; 131 GenePools.group = 0; 132 for (i = 0; i < Populations.size - 2; i++) 133 { 134 Populations.group = i + 2; 135 for (j = 0; j < ExpParams.teamSize; j++) 128 for (var i = 0; i < Populations.size - 2; i++) 129 { 130 for (var j = 0; j < ExpParams.teamSize; j++) 136 131 { 132 var g; //Genotype object 137 133 if (ExpParams.teamCount != 1) 138 GenePools.genotype = Math.random(GenePool.size);134 g = GenePools[0].random(); 139 135 else 140 GenePools.genotype = i; 141 Population.createFromGenotype(); 142 Creature.name = "Member " + j; 136 g = GenePools[0][i]; 137 Populations[i+2].add(g).name = "Member " + j; 143 138 } 144 139 } … … 169 164 170 165 var s = "#Time interval; "; 171 var i = 0; 172 for (i = 0; i < Populations.size - 2; i++) 166 for (var i = 0; i < Populations.size - 2; i++) 173 167 { 174 168 s += "Team " + i + "; "; … … 204 198 function tryCreateHPBox() 205 199 { 206 Populations.group = 0; 207 208 if (Population.size >= ExpParams.hpBoxTotalCount) return; 200 if (Populations[0].size >= ExpParams.hpBoxTotalCount) return; 209 201 210 202 if (Math.rnd01 > ExpParams.hpBoxProbability) return; 211 203 212 var food = Populations .createFromString("//0\nm:Vstyle=hpbox\np:");204 var food = Populations[0].add("//0\nm:Vstyle=hpbox\np:"); 213 205 food.name = "HP Box"; 214 206 food.idleen = ExpParams.hpBoxIdleEnergy; … … 220 212 function tryCreateUpgradeBox() 221 213 { 222 Populations.group = 1; 223 224 if (Population.size >= ExpParams.upgradeBoxTotalCount) return; 214 if (Populations[1].size >= ExpParams.upgradeBoxTotalCount) return; 225 215 226 216 if (Math.rnd01 > ExpParams.upgradeBoxProbability) return; 227 217 228 var weapon = Populations .createFromString("//0\nm:Vstyle=weaponbox\np:");218 var weapon = Populations[1].add("//0\nm:Vstyle=weaponbox\np:"); 229 219 weapon.name = "Weapon Box"; 230 220 weapon.idleen = ExpParams.upgradeBoxIdleEnergy; … … 235 225 236 226 //handle creature placement in the world 237 function onBorn( )227 function onBorn(cr) 238 228 { 239 229 // place newly born creature … … 242 232 while (retry-- && !placed_ok) 243 233 { 244 switch ( Populations.group)234 switch (cr.population.index) 245 235 { 246 236 case 0: //food placement 247 place_centerhead( );237 place_centerhead(cr); 248 238 break; 249 239 case 1: //upgrade placement 250 place_centerhead( );240 place_centerhead(cr); 251 241 break; 252 242 default: 253 Creature.user1 = Vector.new(); 254 Creature.user1.add(0.0); //attack cooldown (0) 255 Creature.user1.add(0.0); //bonus damage (1) 256 Creature.user2 = Vector.new(); 257 Creature.user2.add(0); //kills (0) 258 Creature.user2.add(0); //assists (1) 259 Creature.user2.add(0); //total damage dealt (2) 260 Creature.user2.add(0); //total damage received (3) 261 Creature.user2.add(0); //HP boxes collected (4) 262 Creature.user2.add(0); //Upgrade boxes collected (5) 263 Creature.user3 = Vector.new(); //who dealt damage to this creature 264 Creature.energ0 = ExpParams.creatureStartingEnergy; 265 Creature.energy = Creature.energ0; 266 place_inTeamSpot(); 243 cr.user1 = [0.0, 0.0]; //attack cooldown (0), bonus damage (1) 244 cr.user2 = [0,0,0,0,0,0]; //kills (0), assists (1), total damage dealt (2), total damage received (3), HP boxes collected (4), Upgrade boxes collected (5) 245 cr.user3 = []; //who dealt damage to this creature 246 cr.energ0 = ExpParams.creatureStartingEnergy; 247 cr.energy = cr.energ0; 248 place_inTeamSpot(cr); 267 249 break; 268 250 } 269 251 270 if (! Populations.creatBBCollisions(0))271 placed_ok = 1;252 if (!cr.boundingBoxCollisions(0)) 253 {placed_ok=1; break;} 272 254 } 273 255 if (!placed_ok) … … 276 258 277 259 //place creature in random spot and make it head center of the map 278 function place_centerhead( )260 function place_centerhead(cr) 279 261 { 280 262 var x, y, z; 281 x = (World.wrldsiz - Creature.size_x) * Math.rnd01 - Creature.size_x / 2;282 y = (World.wrldsiz - Creature.size_y) * Math.rnd01 - Creature.size_y / 2;263 x = (World.wrldsiz - cr.size_x) * Math.rnd01 - cr.size_x / 2; 264 y = (World.wrldsiz - cr.size_y) * Math.rnd01 - cr.size_y / 2; 283 265 z = WorldMap.getHeight(x, y); 284 266 … … 287 269 var alpha_rad = vectorsAngle([1.0, 0.0], [hx, hy]); 288 270 289 Creature.rotate(0, 0, alpha_rad);290 Creature.moveAbs(x, y, z - 0.999);271 cr.rotate(0, 0, alpha_rad); 272 cr.moveAbs(x, y, z - 0.999); 291 273 292 274 print("Creature placed in [" + x +" " + y + " " + z); … … 297 279 //Place creature in correct team spot (valid for Team creatures only) 298 280 //Creatures are placed in circle with random rotation (commented out: heading center of the map) in their respective team groups 299 function place_inTeamSpot( )300 { 301 var radius = 360.00 * ( Populations.group- 1) / teams;281 function place_inTeamSpot(cr) 282 { 283 var radius = 360.00 * (cr.population.index - 1) / teams; 302 284 303 285 var x, y, z; 304 x = (ExpParams.teamSpawningAreaSize) * Math.rnd01 - Creature.size_x / 2 - ExpParams.teamSpawningAreaSize/2;305 y = (ExpParams.teamSpawningAreaSize) * Math.rnd01 - Creature.size_y / 2 - ExpParams.teamSpawningAreaSize/2;286 x = (ExpParams.teamSpawningAreaSize) * Math.rnd01 - cr.size_x / 2 - ExpParams.teamSpawningAreaSize/2; 287 y = (ExpParams.teamSpawningAreaSize) * Math.rnd01 - cr.size_y / 2 - ExpParams.teamSpawningAreaSize/2; 306 288 307 289 //vector of length half the world size minus spawning area size … … 324 306 //var alpha_rad = vectorsAngle([1.0, 0.0], [hx, hy]); 325 307 326 Creature.rotate(0, 0, alpha_rad);308 cr.rotate(0, 0, alpha_rad); 327 309 //place it mid-air 328 Creature.moveAbs(x, y, z);310 cr.moveAbs(x, y, z); 329 311 330 312 return ; … … 350 332 { 351 333 var s = "" + Simulator.time + "; "; 352 var i = 0;353 var j = 0;354 334 var total = 0.0; 355 for (i = 0; i < Populations.size - 2; i++) 356 { 357 Populations.group = i + 2; 358 var sum = 0.0; 359 for (j = 0; j < Population.size; j++) 360 { 361 Populations.creature = j; 362 sum += Creature.energy; 363 } 335 for (var i = 2; i < Populations.size; i++) 336 { 337 var pop=Populations[i]; 338 var sum = 0.0; 339 for (var cr in pop) 340 sum += cr.energy; 364 341 s += "" + sum + "; "; 365 s += "" + Population.size + "; ";366 342 s += "" + pop.size + "; "; 343 total += sum; 367 344 } 368 345 if (total < 0) total == 0; … … 376 353 function clearDeadCreatures() 377 354 { 378 var i = 0; 379 var j = 0; 380 for (i = 0; i < Populations.size - 2; i++) 381 { 382 Populations.group = i + 2; 383 for (j = 0; j < Population.size; j++) 355 for (var i = 2; i < Populations.size; i++) 356 { 357 var pop=Populations[i]; 358 for (var j = 0; j < pop.size; j++) 359 { 360 var cr=pop[j]; 361 if (cr.energy <= 0) {pop.kill(cr); j--;} 362 } 363 } 364 } 365 366 function applySuddenDeathModifier() 367 { 368 if (idleSimulationSteps < ExpParams.stagnationInterval) return; 369 370 for (var i = 2; i < Populations.size; i++) 371 for (var cr in Populations[i]) 372 cr.energy -= ExpParams.stagnationHealthReduce; 373 } 374 375 function lowerCooldownCounters() 376 { 377 for (var i = 2; i < Populations.size; i++) 378 { 379 var pop=Populations[i]; 380 for (var cr in pop) 384 381 { 385 Populations.creature = j; 386 if (Creature.energy <= 0) Populations.killSelected(); 387 } 388 } 389 } 390 391 function applySuddenDeathModifier() 392 { 393 if (idleSimulationSteps < ExpParams.stagnationInterval) return; 394 395 var i = 0; 396 var j = 0; 397 for (i = 0; i < Populations.size - 2; i++) 398 { 399 Populations.group = i + 2; 400 for (j = 0; j < Population.size; j++) 401 { 402 Populations.creature = j; 403 Creature.energy -= ExpParams.stagnationHealthReduce; 404 } 405 } 406 } 407 function lowerCooldownCounters() 408 { 409 var i = 0; 410 var j = 0; 411 for (i = 0; i < Populations.size - 2; i++) 412 { 413 Populations.group = i + 2; 414 for (j = 0; j < Population.size; j++) 415 { 416 Populations.creature = j; 417 if (Creature.user1 != null) 382 if (cr.user1 != null) 418 383 { 419 if ( Creature.user1.get(0) > 0) Creature.user1.set(0, Creature.user1.get(0) - 1);420 if ( Creature.user1.get(0) < 0) Creature.user1.set(0,0.0);421 if ( Creature.user1.get(1) > 0) Creature.user1.set(1, Creature.user1.get(1) - ExpParams.upgradeBoxDecay);422 if ( Creature.user1.get(1) < 0) Creature.user1.set(1,0.0);384 if (cr.user1[0] > 0) cr.user1[0]=cr.user1[0] - 1; 385 if (cr.user1[0] < 0) cr.user1[0]=0.0; 386 if (cr.user1[1] > 0) cr.user1[1]=cr.user1[1] - ExpParams.upgradeBoxDecay; 387 if (cr.user1[1] < 0) cr.user1[1]=0.0; 423 388 } 424 389 } … … 428 393 function checkGameState() 429 394 { 430 var i = 0;431 395 var alivePop = 0; 432 for (i = 0; i < Populations.size - 2; i++) 433 { 434 Populations.group = i + 2; 435 if (Population.size > 0) alivePop += 1; 436 } 396 for (var i = 2; i < Populations.size; i++) 397 if (Populations[i].size > 0) alivePop += 1; 437 398 438 399 if (alivePop == 0 && Simulator.time <= 1) … … 444 405 if (alivePop <= 1) 445 406 { 446 for ( i = 0; i < Populations.size - 2; i++)407 for (var i = 2; i < Populations.size; i++) 447 408 { 448 Populations.group = i + 2;449 if ( Population.size > 0)409 var pop=Populations[i]; 410 if (pop.size > 0) 450 411 { 451 Simulator.print("Battle is OVER! The winner is: " + Population.name);412 Simulator.print("Battle is OVER! The winner is: " + pop.name); 452 413 453 414 //write stats of last living creatures 454 415 var f=File.appendDirect("creatures"+battleNumber+".txt","Creature statistics"); 455 var j = 0; 456 for (j = 0; j < Population.size; j++) 416 for (var cr in pop) 457 417 { 458 Populations.creature = j;459 418 //f.writeString("Creature name; Team; Kills; Assists; Total damage dealt; Total damage received; HP boxes collected; Upgrade boxes collected; Lifespan"); 460 if ( Creature.user2 != null)461 f.writeString( Creature.name + "; " + Population.name + "; " + Creature.user2.get(0) + "; " + Creature.user2.get(1) + "; " + Creature.user2.get(2) + "; " + Creature.user2.get(3) + "; " + Creature.user2.get(4) + "; " + Creature.user2.get(5) + "; " + Creature.lifespan + "\n");419 if (cr.user2 != null) 420 f.writeString(cr.name + "; " + pop.name + "; " + cr.user2[0] + "; " + cr.user2[1] + "; " + cr.user2[2] + "; " + cr.user2[3] + "; " + cr.user2[4] + "; " + cr.user2[5] + "; " + cr.lifespan + "\n"); 462 421 } 463 422 … … 502 461 } 503 462 504 if (c1. group == null || c2.group== null)463 if (c1.population == null || c2.population == null) 505 464 { 506 465 //collision of creature without a group … … 510 469 511 470 //first condition should never occur, but who knows? 512 if (c1. group.index < 2 || c2.group.index < 2)471 if (c1.population.index < 2 || c2.population.index < 2) 513 472 { 514 473 //collision with HP Box and Upgrades are handled separately … … 524 483 var dice2 = 0; 525 484 var changed = 0; 526 var i = 0; 527 for (i = 0; i < ExpParams.diceCount; i++) 485 for (var i = 0; i < ExpParams.diceCount; i++) 528 486 { 529 487 dice1 = dice1 + Math.random(ExpParams.diceSides) + 1; … … 534 492 energy1 += ExpParams.upgradeMultiplier * c1.user1.get(1); 535 493 energy2 += ExpParams.upgradeMultiplier * c2.user1.get(1); 536 if (c1. group == c2.group)494 if (c1.population == c2.population) 537 495 { 538 496 energy1 = ExpParams.friendlyFireDamageMultiplier * energy1; … … 547 505 if (c2.user2 == null) stop("3"); 548 506 549 if (c2.user1 .get(0)<= 0 && energy2 > 0)507 if (c2.user1[0] <= 0 && energy2 > 0) 550 508 { 551 509 changed = 1; … … 553 511 c1.energy = c1.energy - energy2; 554 512 if (c1.energy < 0) c1.energy = 0; 555 print(c2.name + " [" + c2. group.name + "] rolled " + dice2 + " and dealt " + energy2 + " [+" + (ExpParams.upgradeMultiplier * c2.user1.get(1)) +" bonus] damage to " + c1.name + " [" + c1.group.name + "]");513 print(c2.name + " [" + c2.population.name + "] rolled " + dice2 + " and dealt " + energy2 + " [+" + (ExpParams.upgradeMultiplier * c2.user1[1]) +" bonus] damage to " + c1.name + " [" + c1.population.name + "]"); 556 514 c2.user1.set(0, ExpParams.attackCooldown); 557 c2.user2.set(2, c2.user2.get(2) + energy1); 558 c1.user2.set(3, c1.user2.get(3) + energy1); 559 var vect = Vector.new(); 560 vect.add(c2.uid); 561 vect.add(c2.name); 515 c2.user2.set(2, c2.user2[2] + energy1); 516 c1.user2.set(3, c1.user2[3] + energy1); 517 var vect = [c2.uid,c2.name]; 562 518 var arrindex = arrayContains(c1.user3, 0, c2.uid); 563 519 if (arrindex != -1) 564 520 { 565 vect.add(energy2 + c1.user3 .get(arrindex).get(2));566 c1.user3 .set(arrindex, vect);521 vect.add(energy2 + c1.user3[arrindex][2]); 522 c1.user3[arrindex]=vect; 567 523 } 568 524 else … … 572 528 c1.user3.add(vect); 573 529 if (c1.energy > 0) 574 { 575 c2.user2.set(1, c2.user2.get(1) + 1); //increase assists statistic 576 } 530 c2.user2[1] = c2.user2[1] + 1; //increase assists statistic 577 531 } 578 532 if (c1.energy <= 0) 579 533 { 580 c2.user2 .set(0, c2.user2.get(0) + 1); //increase kills statistic534 c2.user2[0] = c2.user2[0] + 1; //increase kills statistic 581 535 kill_c1 = 1; 582 536 } 583 537 } 584 538 585 if (c1.user1 .get(0)<= 0 && energy1 > 0)539 if (c1.user1[0] <= 0 && energy1 > 0) 586 540 { 587 541 changed = 1; … … 589 543 c2.energy = c2.energy - energy1; 590 544 if (c2.energy < 0) c2.energy = 0; 591 print(c1.name + " [" + c1. group.name + "] rolled " + dice1 + " and dealt " + energy1 + " [+" + (ExpParams.upgradeMultiplier * c1.user1.get(1)) +" bonus] damage to " + c2.name + " [" + c2.group.name + "]");592 c1.user1 .set(0, ExpParams.attackCooldown);593 c1.user2 .set(2, c1.user2.get(2) + energy1);594 c2.user2 .set(3, c2.user2.get(3) + energy1);545 print(c1.name + " [" + c1.population.name + "] rolled " + dice1 + " and dealt " + energy1 + " [+" + (ExpParams.upgradeMultiplier * c1.user1[1]) +" bonus] damage to " + c2.name + " [" + c2.population.name + "]"); 546 c1.user1[0] = ExpParams.attackCooldown; 547 c1.user2[2] = c1.user2[2] + energy1; 548 c2.user2[3] = c2.user2[3] + energy1; 595 549 var vect = Vector.new(); 596 550 vect.add(c1.uid); … … 599 553 if (arrindex != -1) 600 554 { 601 vect.add(energy1 + c2.user3 .get(arrindex).get(2));602 c2.user3 .set(arrindex, vect);555 vect.add(energy1 + c2.user3[arrindex][2]); 556 c2.user3[arrindex] = vect; 603 557 } 604 558 else … … 609 563 if (c2.energy > 0) 610 564 { 611 c1.user2 .set(1, c1.user2.get(1) + 1); //increase assists statistic565 c1.user2[1] = c1.user2[1] + 1; //increase assists statistic 612 566 } 613 567 } 614 568 if (c2.energy <= 0) 615 569 { 616 c1.user2 .set(0, c1.user2.get(0) + 1); //increase kills statistic570 c1.user2[0] = c1.user2[0] + 1; //increase kills statistic 617 571 kill_c2 = 1; 618 572 } … … 626 580 //resolve kills 627 581 if (kill_c1 == 1) 628 { 629 Populations.group = c1.group.index; 630 Populations.creature = c1.group.findUID(c1.uid); 631 if (Populations.creature == -1) stop("4"); 632 Populations.killSelected(); 633 } 582 c1.population.kill(c1); 634 583 if (kill_c2 == 1) 635 { 636 Populations.group = c2.group.index; 637 Populations.creature = c2.group.findUID(c2.uid); 638 if (Populations.creature == -1) stop("4"); 639 Populations.killSelected(); 640 } 584 c2.population.kill(c2); 641 585 } 642 586 … … 647 591 648 592 //collect HP Box (by eating it :D) 649 print(Collision.Creature2.name + " [" + Collision.Creature2. group.name + "] picked a HP box");650 Collision.Creature2.user2 .set(4, Collision.Creature2.user2.get(4) + 1);651 Collision.Creature1.energy_m = Collision.Creature1.energy_m +Collision.Creature1.energy;652 Collision.Creature2.energy_p = Collision.Creature2.energy_p +Collision.Creature1.energy;593 print(Collision.Creature2.name + " [" + Collision.Creature2.population.name + "] picked a HP box"); 594 Collision.Creature2.user2[4] = Collision.Creature2.user2[4] + 1; 595 Collision.Creature1.energy_m += Collision.Creature1.energy; 596 Collision.Creature2.energy_p += Collision.Creature1.energy; 653 597 654 598 //kill HP Box 655 Populations.group = Collision.Creature1.group.index; 656 Populations.creature = Collision.Creature1.group.findUID(Collision.Creature1.uid); 657 Populations.killSelected(); 599 Collision.Creature1.population.kill(Collision.Creature1); 658 600 659 601 writeTeamStatistics(); … … 666 608 667 609 //collect Upgrade Box (by eating it :D) 668 print(Collision.Creature2.name + " [" + Collision.Creature2. group.name + "] picked an upgrade box");669 Collision.Creature2.user2 .set(5, Collision.Creature2.user2.get(5) + 1);670 Collision.Creature1.energy_m = Collision.Creature1.energy_m +Collision.Creature1.energy;671 Collision.Creature2.user1 .set(1, Collision.Creature2.user1.get(1) + Collision.Creature1.energy);610 print(Collision.Creature2.name + " [" + Collision.Creature2.population.name + "] picked an upgrade box"); 611 Collision.Creature2.user2[5] = Collision.Creature2.user2[5] + 1; 612 Collision.Creature1.energy_m += Collision.Creature1.energy; 613 Collision.Creature2.user1[1] = Collision.Creature2.user1[1] + Collision.Creature1.energy; 672 614 673 615 //kill Upgrade Box 674 Populations.group = Collision.Creature1.group.index; 675 Populations.creature = Collision.Creature1.group.findUID(Collision.Creature1.uid); 676 Populations.killSelected(); 616 Collision.Creature1.population.kill(Collision.Creature1); 677 617 678 618 writeTeamStatistics(); … … 681 621 //function executed on Creature death 682 622 //TODO: implement some statistics for dieing creature 683 function onDied( )623 function onDied(cr) 684 624 { 685 625 //ignore death of hp boxes and upgrades 686 if ( Populations.group< 2)626 if (cr.population.index < 2) 687 627 return ; 688 628 689 print(Creature.name + " was killed"); 690 var i = 0; 691 for (i = 0; i < Creature.user3.size; i++) 692 { 693 print(Creature.user3.get(i).get(1) + " dealt " + Creature.user3.get(i).get(2) + " damage"); 694 } 629 print(cr.name + " was killed"); 630 for (var dam in cr.user3) 631 print(dam[1] + " dealt " + dam[2] + " damage"); 695 632 696 633 var f=File.appendDirect("creatures"+battleNumber+".txt","Creature statistics"); 697 634 //f.writeString("Creature name; Team; Kills; Assists; Total damage dealt; Total damage received; HP boxes collected; Upgrade boxes collected; Lifespan"); 698 f.writeString( Creature.name + "; " + Population.name + "; " + Creature.user2.get(0) + "; " + Creature.user2.get(1) + "; " + Creature.user2.get(2) + "; " + Creature.user2.get(3) + "; " + Creature.user2.get(4) + "; " + Creature.user2.get(5) + "; " + Creature.lifespan + "\n");635 f.writeString(cr.name + "; " + cr.population.name + "; " + cr.user2[0] + "; " + cr.user2[1] + "; " + cr.user2[2] + "; " + cr.user2[3] + "; " + cr.user2[4] + "; " + cr.user2[5] + "; " + cr.lifespan + "\n"); 699 636 f.close(); 700 637
Note: See TracChangeset
for help on using the changeset viewer.