Changeset 485 for experiments/frams/capture-the-flag/data
- Timestamp:
- 03/26/16 02:33:51 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experiments/frams/capture-the-flag/data/scripts/capture-the-flag.expdef
r480 r485 89 89 var pool=GenePools[0]; 90 90 pool.name = "Team1"; 91 pool.fitness = "return this.user3;";91 pool.fitness = "return 0;"; 92 92 while (pool.size > 0) 93 93 pool.delete(0); … … 111 111 pop.othermask = 0x60001; 112 112 pool=GenePools.addGroup("Team"+i); 113 pool.fitness = "return this.user3;";113 pool.fitness = "return 0;"; 114 114 } 115 115 … … 208 208 cr.signals[0].flavor = team; 209 209 cr.signals[0].power=1000; 210 cr. user1= 0;211 cr. user2= 0;212 cr. user3= 0;210 cr.data->taken = 0; 211 cr.data->owner = 0; 212 cr.data->cooldown = 0; 213 213 214 214 var crX, crY; … … 228 228 crY = -5; 229 229 cr.moveAbs(flagsX[team] + crX, flagsY[team] + crY, 0); 230 cr. user1= 0;231 cr. user2= 0;232 cr. user3= 0;230 cr.data->holding = 0; 231 cr.data->flag = 0; 232 cr.data->score = 0; 233 233 } 234 234 } … … 256 256 var pop=Populations[team]; 257 257 258 if (pop[0]. user3> 0)259 pop[0]. user3-= 1;258 if (pop[0].data->cooldown > 0) 259 pop[0].data->cooldown -= 1; 260 260 261 261 for (player = 1; player < pop.size; player++){ 262 262 var cr=pop[player]; 263 if (cr. user1== 1){264 cr. user2.moveAbs(cr.pos_x, cr.pos_y, cr.size_z + 1);263 if (cr.data->holding == 1){ 264 cr.data->flag.moveAbs(cr.pos_x, cr.pos_y, cr.size_z + 1); 265 265 } 266 266 } … … 288 288 function takeFlag(flag, creature){ 289 289 //If the cooldown is on - do nothing 290 if (flag. user3> 0)290 if (flag.data->cooldown > 0) 291 291 return; 292 292 293 293 //Take flag by changing its flavour and setting flag in player and player in flag fields 294 294 flag.signals[0].flavor = flag.population.index + 100; 295 flag. user1= 1;296 flag. user2= creature;297 creature. user1= 1;298 creature. user2= flag;295 flag.data->taken = 1; 296 flag.data->owner = creature; 297 creature.data->holding = 1; 298 creature.data->flag = flag; 299 299 300 300 //Score points for taking a flag 301 creature. user3+= ExpProperties.pointsCapture;301 creature.data->score += ExpProperties.pointsCapture; 302 302 303 303 // Simulator.print("Flag "+(flag.group.index+1)+" taken by team "+(creature.group.index+1)); … … 312 312 //Retrieve flag by changing its flavour and deleting it from player and player from flag 313 313 flag.signals[0].flavor = flag.population.index; 314 flag. user1= 0;315 316 flag. user2.user1= 0;317 flag. user2.user2= 0;318 319 flag. user2= 0;314 flag.data->taken = 0; 315 316 flag.data->owner.data->holding = 0; 317 flag.data->owner.data->flag = 0; 318 319 flag.data->owner = 0; 320 320 321 321 //Set cooldown for taking a flag 322 flag. user3= 1000;322 flag.data->cooldown = 1000; 323 323 324 324 placeFlag(flag); 325 325 326 326 //Score points for retrieving a flag 327 creature. user3+= ExpProperties.pointsRetrieve;327 creature.data->score += ExpProperties.pointsRetrieve; 328 328 329 329 // Simulator.print("Flag "+ (flag.group.index+1) +" retrieved"); … … 336 336 function scoreFlag(flag, creature){ 337 337 //Put the flag back on its spot and delete references between player and flag 338 creature. user2.signals[0].flavor = creature.user2.population.index;339 creature. user2.user1= 0;340 creature. user2.user2= 0;341 342 placeFlag(creature. user2);343 344 creature. user1= 0;345 creature. user2= 0;338 creature.data->flag.signals[0].flavor = creature.data->flag.population.index; 339 creature.data->flag.data->taken = 0; 340 creature.data->flag.data->owner = 0; 341 342 placeFlag(creature.data->flag); 343 344 creature.data->holding = 0; 345 creature.data->flag = 0; 346 346 347 347 //Score points for scoring a flag 348 creature. user3+= ExpProperties.pointsScoring;348 creature.data->score += ExpProperties.pointsScoring; 349 349 350 350 // Simulator.print("Team "+ (creature.group.index + 1) +" scored"); … … 382 382 if (colFlag == 1){ 383 383 //Collision with my flag which is taken 384 if (flag.population.index == creature.population.index && flag. user1== 1){384 if (flag.population.index == creature.population.index && flag.data->taken == 1){ 385 385 retrieveFlag(flag, creature); 386 386 } //Collision with my flag which is not taken while carrying another team's flag 387 else if (flag.population.index == creature.population.index && flag. user1 == 0 && creature.user1 == 1 && flag.user3!= 1){387 else if (flag.population.index == creature.population.index && flag.data->taken == 0 && creature.data->holding == 1 && flag.data->cooldown != 1){ 388 388 scoreFlag(flag, creature); 389 389 } //Collision with another team's flag which is not taken while not carrying any flag 390 else if (flag.population.index != creature.population.index && flag. user1 == 0 && creature.user1 == 0 && flag.user3!= 1){390 else if (flag.population.index != creature.population.index && flag.data->taken == 0 && creature.data->holding == 0 && flag.data->cooldown != 1){ 391 391 takeFlag(flag, creature); 392 392 } … … 397 397 if (c1.population.index != c2.population.index){ 398 398 //If player 1 has a flag ... 399 if (c1. user1== 1){399 if (c1.data->holding == 1){ 400 400 // ... and the flag is of my team ... 401 if (c2.population.index == c1. user2.population.index){401 if (c2.population.index == c1.data->flag.population.index){ 402 402 //... retrieve it 403 retrieveFlag(c1. user2, c2);403 retrieveFlag(c1.data->flag, c2); 404 404 } 405 405 } 406 406 //If player 2 has a flag ... 407 if (c2. user1== 1){407 if (c2.data->holding == 1){ 408 408 // ... and the flag is of my team ... 409 if (c1.population.index == c2. user2.population.index){409 if (c1.population.index == c2.data->flag.population.index){ 410 410 //... retrieve it 411 retrieveFlag(c2. user2, c1);411 retrieveFlag(c2.data->flag, c1); 412 412 } 413 413 }
Note: See TracChangeset
for help on using the changeset viewer.