Changeset 631 for experiments
- Timestamp:
- 11/09/16 04:29:53 (8 years ago)
- Location:
- experiments/frams/deathmatch/data/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
experiments/frams/deathmatch/data/scripts/deathmatch-utils.inc
r231 r631 56 56 for (i = 0; i < array.size; i++) 57 57 { 58 if (array .get(i)!= null)59 if (array .get(i).get(column)== value) return i;58 if (array[i] != null) 59 if (array[i][column] == value) return i; 60 60 } 61 61 return -1; -
experiments/frams/deathmatch/data/scripts/deathmatch.expdef
r537 r631 184 184 levelNumber = ExpProperties.level; 185 185 186 var level = levels .get(levelNumber);186 var level = levels[levelNumber]; 187 187 Simulator.print("Level #" + (levelNumber + 1) + ": " + level[0]); 188 188 … … 205 205 food.name = "HP Box"; 206 206 food.idleen = ExpProperties.hpBoxIdleEnergy; 207 food.energ 0 = ExpProperties.hpBoxStartingEnergy;208 food.energy = food.energ 0;207 food.energy0 = ExpProperties.hpBoxStartingEnergy; 208 food.energy = food.energy0; 209 209 food.nnenabled = 0; 210 210 } … … 219 219 weapon.name = "Weapon Box"; 220 220 weapon.idleen = ExpProperties.upgradeBoxIdleEnergy; 221 weapon.energ 0 = ExpProperties.upgradeBoxStartingEnergy;222 weapon.energy = weapon.energ 0;221 weapon.energy0 = ExpProperties.upgradeBoxStartingEnergy; 222 weapon.energy = weapon.energy0; 223 223 weapon.nnenabled = 0; 224 224 } … … 241 241 break; 242 242 default: 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 = ExpProperties.creatureStartingEnergy; 247 cr.energy = cr.energ0; 243 cr.data->cooldown=0.0; 244 cr.data->bonusdamage=0.0; 245 cr.data->kills=0; 246 cr.data->assists=0; 247 cr.data->damagedealt=0; 248 cr.data->damagereceived=0; 249 cr.data->hpcollected=0; 250 cr.data->upgradecollected=0; 251 cr.data->damagefrom=[]; //who dealt damage to this creature 252 cr.energy0 = ExpProperties.creatureStartingEnergy; 253 cr.energy = cr.energy0; 248 254 place_inTeamSpot(cr); 249 255 break; … … 261 267 { 262 268 var x, y, z; 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; 269 var size=cr.bboxSize; 270 x = (World.wrldsiz - size.x) * Math.rnd01 - size.x / 2; 271 y = (World.wrldsiz - size.y) * Math.rnd01 - size.y / 2; 265 272 z = WorldMap.getHeight(x, y); 266 273 … … 270 277 271 278 cr.rotate(0, 0, alpha_rad); 272 cr. moveAbs(x, y, z - 0.999);279 cr.locationSetBboxLow(x, y, z - 0.999); 273 280 274 281 print("Creature placed in [" + x +" " + y + " " + z); … … 284 291 285 292 var x, y, z; 286 x = (ExpProperties.teamSpawningAreaSize) * Math.rnd01 - cr. size_x / 2 - ExpProperties.teamSpawningAreaSize/2;287 y = (ExpProperties.teamSpawningAreaSize) * Math.rnd01 - cr. size_y / 2 - ExpProperties.teamSpawningAreaSize/2;293 x = (ExpProperties.teamSpawningAreaSize) * Math.rnd01 - cr.bboxSize.x / 2 - ExpProperties.teamSpawningAreaSize/2; 294 y = (ExpProperties.teamSpawningAreaSize) * Math.rnd01 - cr.bboxSize.y / 2 - ExpProperties.teamSpawningAreaSize/2; 288 295 289 296 //vector of length half the world size minus spawning area size … … 308 315 cr.rotate(0, 0, alpha_rad); 309 316 //place it mid-air 310 cr. moveAbs(x, y, z);317 cr.locationSetBboxLow(x, y, z); 311 318 312 319 return ; … … 331 338 function writeTeamStatistics() 332 339 { 333 var s = "" + Simulator.time+ "; ";340 var s = string(Simulator.stepNumber) + "; "; 334 341 var total = 0.0; 335 342 for (var i = 2; i < Populations.size; i++) … … 380 387 for (var cr in pop) 381 388 { 382 if (cr. user1!= null)389 if (cr.data->cooldown != null) 383 390 { 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] - ExpProperties.upgradeBoxDecay; 387 if (cr.user1[1] < 0) cr.user1[1]=0.0; 391 if (cr.data->cooldown > 0) cr.data->cooldown-=1; 392 if (cr.data->cooldown < 0) cr.data->cooldown=0.0; 393 } 394 if (cr.data->bonusdamage != null) 395 { 396 if (cr.data->bonusdamage > 0) cr.data->bonusdamage-=ExpProperties.upgradeBoxDecay; 397 if (cr.data->bonusdamage < 0) cr.data->bonusdamage=0.0; 388 398 } 389 399 } … … 397 407 if (Populations[i].size > 0) alivePop += 1; 398 408 399 if (alivePop == 0 && Simulator. time<= 1)409 if (alivePop == 0 && Simulator.stepNumber <= 1) 400 410 { 401 411 onExpInit(); //do initialization for user, because he forgot to do so … … 417 427 { 418 428 //f.writeString("Creature name; Team; Kills; Assists; Total damage dealt; Total damage received; HP boxes collected; Upgrade boxes collected; Lifespan"); 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");429 if (cr.data->kills != null) 430 f.writeString(cr.name + "; " + pop.name + "; " + cr.data->kills + "; " + cr.data->assists + "; " + cr.data->damagedealt + "; " + cr.data->damagereceived + "; " + cr.data->hpcollected + "; " + cr.data->upgradecollected + "; " + cr.lifespan + "\n"); 421 431 } 422 432 … … 490 500 var energy1 = 0.0 + ExpProperties.creatureDamage * dice1; 491 501 var energy2 = 0.0 + ExpProperties.creatureDamage * dice2; 492 energy1 += ExpProperties.upgradeMultiplier * c1. user1.get(1);493 energy2 += ExpProperties.upgradeMultiplier * c2. user1.get(1);502 energy1 += ExpProperties.upgradeMultiplier * c1.data->bonusdamage; 503 energy2 += ExpProperties.upgradeMultiplier * c2.data->bonusdamage; 494 504 if (c1.population == c2.population) 495 505 { … … 498 508 } 499 509 500 if (c1.user1 == null) stop("3"); 501 if (c1.user2 == null) stop("3"); 502 if (c1.user3 == null) stop("3"); 503 if (c2.user1 == null) stop("3"); 504 if (c2.user2 == null) stop("3"); 505 if (c2.user2 == null) stop("3"); 506 507 if (c2.user1[0] <= 0 && energy2 > 0) 510 if (c1.data->cooldown == null) stop("3"); 511 if (c2.data->cooldown == null) stop("3"); 512 513 if (c2.data->cooldown <= 0 && energy2 > 0) 508 514 { 509 515 changed = 1; … … 511 517 c1.energy = c1.energy - energy2; 512 518 if (c1.energy < 0) c1.energy = 0; 513 print(c2.name + " [" + c2.population.name + "] rolled " + dice2 + " and dealt " + energy2 + " [+" + (ExpProperties.upgradeMultiplier * c2. user1[1]) +" bonus] damage to " + c1.name + " [" + c1.population.name + "]");514 c2. user1.set(0, ExpProperties.attackCooldown);515 c2. user2.set(2, c2.user2[2] + energy1);516 c1. user2.set(3, c1.user2[3] + energy1);519 print(c2.name + " [" + c2.population.name + "] rolled " + dice2 + " and dealt " + energy2 + " [+" + (ExpProperties.upgradeMultiplier * c2.data->bonusdamage) +" bonus] damage to " + c1.name + " [" + c1.population.name + "]"); 520 c2.data->cooldown = ExpProperties.attackCooldown; 521 c2.data->damagedealt += energy1; 522 c1.data->damagereceived += energy1; 517 523 var vect = [c2.uid,c2.name]; 518 var arrindex = arrayContains(c1. user3, 0, c2.uid);524 var arrindex = arrayContains(c1.data->damagefrom, 0, c2.uid); 519 525 if (arrindex != -1) 520 526 { 521 vect.add(energy2 + c1. user3[arrindex][2]);522 c1. user3[arrindex]=vect;527 vect.add(energy2 + c1.data->damagefrom[arrindex][2]); 528 c1.data->damagefrom[arrindex]=vect; 523 529 } 524 530 else 525 531 { 526 532 vect.add(energy2); 527 if (c1. user3 == null) c1.user3 = Vector.new();528 c1. user3.add(vect);533 if (c1.data->damagefrom == null) c1.data->damagefrom = []; 534 c1.data->damagefrom.add(vect); 529 535 if (c1.energy > 0) 530 c2. user2[1] = c2.user2[1] +1; //increase assists statistic536 c2.data->assists += 1; //increase assists statistic 531 537 } 532 538 if (c1.energy <= 0) 533 539 { 534 c2. user2[0] = c2.user2[0] +1; //increase kills statistic540 c2.data->kills += 1; //increase kills statistic 535 541 kill_c1 = 1; 536 542 } 537 543 } 538 544 539 if (c1. user1[0]<= 0 && energy1 > 0)545 if (c1.data->cooldown <= 0 && energy1 > 0) 540 546 { 541 547 changed = 1; … … 543 549 c2.energy = c2.energy - energy1; 544 550 if (c2.energy < 0) c2.energy = 0; 545 print(c1.name + " [" + c1.population.name + "] rolled " + dice1 + " and dealt " + energy1 + " [+" + (ExpProperties.upgradeMultiplier * c1. user1[1]) +" bonus] damage to " + c2.name + " [" + c2.population.name + "]");546 c1. user1[0]= ExpProperties.attackCooldown;547 c1. user2[2] = c1.user2[2] +energy1;548 c2. user2[3] = c2.user2[3] +energy1;551 print(c1.name + " [" + c1.population.name + "] rolled " + dice1 + " and dealt " + energy1 + " [+" + (ExpProperties.upgradeMultiplier * c1.data->bonusdamage) +" bonus] damage to " + c2.name + " [" + c2.population.name + "]"); 552 c1.data->cooldown = ExpProperties.attackCooldown; 553 c1.data->damagedealt += energy1; 554 c2.data->damagereceived += energy1; 549 555 var vect = Vector.new(); 550 556 vect.add(c1.uid); 551 557 vect.add(c1.name); 552 var arrindex = arrayContains(c2. user3, 0, c1.uid);558 var arrindex = arrayContains(c2.data->damagefrom, 0, c1.uid); 553 559 if (arrindex != -1) 554 560 { 555 vect.add(energy1 + c2. user3[arrindex][2]);556 c2. user3[arrindex] = vect;561 vect.add(energy1 + c2.data->damagefrom[arrindex][2]); 562 c2.data->damagefrom[arrindex] = vect; 557 563 } 558 564 else 559 565 { 560 566 vect.add(energy1); 561 if (c2. user3 == null) c2.user3 = Vector.new();562 c2. user3.add(vect);567 if (c2.data->damagefrom == null) c2.data->damagefrom = []; 568 c2.data->damagefrom.add(vect); 563 569 if (c2.energy > 0) 564 570 { 565 c1. user2[1] = c1.user2[1] +1; //increase assists statistic571 c1.data->assists += 1; //increase assists statistic 566 572 } 567 573 } 568 574 if (c2.energy <= 0) 569 575 { 570 c1. user2[0] = c1.user2[0] +1; //increase kills statistic576 c1.data->kills += 1; //increase kills statistic 571 577 kill_c2 = 1; 572 578 } … … 592 598 //collect HP Box (by eating it :D) 593 599 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; 600 Collision.Creature2.data->hpcollected += 1; 601 Collision.Creature1.transferEnergyTo(Collision.Creature2,Collision.Creature1.energy); 597 602 598 603 //kill HP Box … … 609 614 //collect Upgrade Box (by eating it :D) 610 615 print(Collision.Creature2.name + " [" + Collision.Creature2.population.name + "] picked an upgrade box"); 611 Collision.Creature2. user2[5] = Collision.Creature2.user2[5] +1;612 Collision.Creature 1.energy_m+= Collision.Creature1.energy;613 Collision.Creature 2.user1[1] = Collision.Creature2.user1[1] + Collision.Creature1.energy;616 Collision.Creature2.data->upgradecollected += 1; 617 Collision.Creature2.data->bonusdamage += Collision.Creature1.energy; 618 Collision.Creature1.energy = 0; 614 619 615 620 //kill Upgrade Box … … 628 633 629 634 print(cr.name + " was killed"); 630 for (var dam in cr. user3)635 for (var dam in cr.data->damagefrom) 631 636 print(dam[1] + " dealt " + dam[2] + " damage"); 632 637 633 638 var f=File.appendDirect("creatures"+battleNumber+".txt","Creature statistics"); 634 639 //f.writeString("Creature name; Team; Kills; Assists; Total damage dealt; Total damage received; HP boxes collected; Upgrade boxes collected; Lifespan"); 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");640 f.writeString(cr.name + "; " + cr.population.name + "; " + cr.data->kills + "; " + cr.data->assists + "; " + cr.data->damagedealt + "; " + cr.data->damagereceived + "; " + cr.data->hpcollected + "; " + cr.data->upgradecollected + "; " + cr.lifespan + "\n"); 636 641 f.close(); 637 642
Note: See TracChangeset
for help on using the changeset viewer.