The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.15 (Linux)
File Line Function
/showthread.php 906 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Natural Wasp
#1
I made a little program for a wasp to it move more natural
What it does:
-wasp looks like flying totally pointless (but it's not)
-wasp is harder to shoot down
-wasp drops OrgaMatter on buildings and robots (not every one - you can check)
-when no buildings or robots on map, wasp steals your resources Smile)

I know it's so much imperfect and the code has a lot of bugs - I'm just a begginer.
I just want to show that wasps can move more naturally and be more annoying (like in real!) - maybe it's something what you can do batter in Colobot Gold? Wasp is not a robot and I think it shouldn't move like robot.

The code is made for Tropica freemission map.
I placed there "CreateObject pos=65.58;232.20 dir=0.0 type=AlienNest"
and "CreateObject pos= -55; 243 cmdline= -55; 243; -62; 234 dir=0.0 type=AlienQueen script1="alienqueen.txt" run=1"
where script alienqueen.txt produces an AlienWasp when there are < 30 of them Smile



Here it is:
Code:
void object::grabber()
{
while (this.load == null)
{
motor(0,0);
while (this.altitude > 1)
{
jet(-1);
wait(0.1);
continue;
}
jet(-1);
wait(1.5);
grab();
break;
}

}

void object::fly()
{
float rand1 = rand(), rand2 = rand();

  jet(1);
  wait(0.8);
           motor(1, 0.5+rand1);
  jet(0.8);
  wait(0.8);
           motor(0.5+rand2, 1);
  jet(1);
  wait(1.6);
      motor(1, 0.5+rand2);
  jet(0.7);
      wait(0.8); 
       motor(1,1);         
}

void object::Fight()
{
point dest;
int alien[], j = 0; // aliens for wasp ;)
//alien[j++] = WingedGrabber;
//alien[j++] = TrackedGrabber;
//alien[j++] = WheeledGrabber;
//alien[j++] = LeggedGrabber;
alien[j++] = WingedShooter;
alien[j++] = TrackedShooter;
alien[j++] = WheeledShooter;
alien[j++] = LeggedShooter;
alien[j++] = WingedOrgaShooter;
alien[j++] = TrackedOrgaShooter;
alien[j++] = WheeledOrgaShooter;
alien[j++] = LeggedOrgaShooter;
alien[j++] = WingedSniffer;
alien[j++] = TrackedSniffer;
alien[j++] = WheeledSniffer;
alien[j++] = LeggedSniffer;
alien[j++] = Thumper;
alien[j++] = PhazerShooter;
alien[j++] = Recycler;
alien[j++] = Shielder;
alien[j++] = Subber;
//alien[j++] = Me;

alien[j++] = Houston; 
alien[j++] = ExchangePost; 
alien[j++] = RadarStation; 
//alien[j++] = Derrick; 
//alien[j++] = Converter; 
alien[j++] = PowerPlant; 
alien[j++] = NuclearPlant; 
alien[j++] = BotFactory; 
alien[j++] = RepairCenter; 
alien[j++] = PowerStation; 
alien[j++] = DefenseTower; 
alien[j++] = PowerCaptor; 
alien[j++] = AutoLab; 
alien[j++] = ResearchCenter; 

object item;
point dustbin;
dustbin.x = 34;
dustbin.y = 240;

item = radar(OrgaMatter, 0, 360, 0, 1000);
if (item == null)
{
jet(1);  
dest = position;
dest.x += (rand()-0.5)*10;
dest.y += (rand()-0.5)*10;
goto(dest);  
produce(position, 0, OrgaMatter, "");
wait(2);
}
else
{
jet(1);
produce(position, 0, OrgaMatter, "");
goto(item.position);
grabber();
   if (this.load == null)
   {
   Fight(); // sometimes has problem with grab so tries again
}
item = radar(alien, 0, 360, 0, 10000, FilterOnlyLanding);
if (item == null)
{
Steal();
GoBack();
}
else
{
while (distance(position, item.position) > 30)
{
item = radar(alien, 0, 360, 0, 10000, FilterOnlyLanding);
if (item == null)
{
SuperWasp(); //enemy may become destroyed while wasp was flying there
}
else
{
turn (direction(item.position));
fly();
}
}
   
while (distance(position, item.position) < 30)
{
item = radar(alien, 0, 360, 0, 10000, FilterOnlyLanding);
   if (item == null)
   {
   SuperWasp();
}

while (distance(position, item.position) > 10)
{
item = radar(alien, 0, 360, 0, 10000, FilterOnlyLanding);
if (item == null)
{
Steal();
}
else
{
jet(1);
turn(direction(item.position));
motor(1,1);
}
}
                      
while (distance(position, item.position) <= 10)
{
item = radar(alien, 0, 360, 0, 10000, FilterOnlyLanding);
if (item == null)
{
Steal();
}
else
{
jet(1);
if (this.load != null)
{
motor(0, 1);
jet(1);
wait(0.1);
drop(); // drop Orga Matter not so accurately
fly();
}
else
{
Steal();
GoBack();
}
}
break;
}
break;
}
   
}

}
}

void object::Steal()
{
point dest;
point dustbin;
dustbin.x = 34;
dustbin.y = 240;
object item;
object thing;
object item2;

int list[], i = 0;
list[i++] = Titanium;
list[i++] = PowerCell;
list[i++] = NuclearCell;

GoBack();

if (this.load != null)
{
drop();
}

item = radar(list, 0, 360, 0, 10000, -1);
if (item == null)
{
while (distance(position, dustbin) > 30)
{
turn (direction(dustbin));
fly();
}
while (distance(position, dustbin) < 30)
{
jet(1);  
dest = position;
dest.x += (rand()-0.5)*10;
dest.y += (rand()-0.5)*10;
goto(dest);  
break;
}
}
else
{   
while (distance(position, item.position) > 30) // go there
{
item2 = radar(list, 0, 360, 30, 10000);
if (item2 != null)
{
item2 == item;
turn (direction(item.position));
fly();
}
else
{
SuperWasp();
}

}
while (distance(position, item.position) < 30) // wasp close to target, need to be more accuretely
{
item = radar(list, 0, 360, 0, 10000);
if (item == null)
{
SuperWasp();
}
if (distance2d(position, item.position) > 10)
{
jet(1);
turn(direction(item.position));
move(distance(position, item.position));
}
if (distance2d(position, item.position) <= 10)
{
motor(0,0);
jet(1);
turn(direction(item.position));
move(distance2d(position, item.position));
grabber();
if (this.load == null)
{
item = radar(list, 0, 360, 0, 10000);
goto(item.position);
grabber();
}
jet(1);
wait(0.2);
motor(1, 0.7);
wait(1.5);
SuperWasp();
}
break;
}
}


jet(1);
turn(direction(dustbin));
while (distance(position, dustbin) > 30)
{
turn (direction(dustbin));
fly();
}
while (distance(position, dustbin) > 30)
{
turn(direction(dustbin));
move(10);
if (this.load != null)
{
drop();
}
}
}

void object::GoBack()
{
point dustbin; // position where wasps collect stolen items
dustbin.x = 34;
dustbin.y = 240;

jet(1);
turn(direction(dustbin));
while (distance(position, dustbin) > 20)
{
turn (direction(dustbin));
fly();
}
while (distance(position, dustbin) < 20)
{
if (this.load != null)
{
goto(dustbin);
drop(); // Anything
break;
}
break;
}
}


extern void object::SuperWasp()
{
int alien[], j = 0; // aliens for wasp ;)
//alien[j++] = WingedGrabber;
//alien[j++] = TrackedGrabber;
//alien[j++] = WheeledGrabber;
//alien[j++] = LeggedGrabber;
alien[j++] = WingedShooter;
alien[j++] = TrackedShooter;
alien[j++] = WheeledShooter;
alien[j++] = LeggedShooter;
alien[j++] = WingedOrgaShooter;
alien[j++] = TrackedOrgaShooter;
alien[j++] = WheeledOrgaShooter;
alien[j++] = LeggedOrgaShooter;
alien[j++] = WingedSniffer;
alien[j++] = TrackedSniffer;
alien[j++] = WheeledSniffer;
alien[j++] = LeggedSniffer;
alien[j++] = Thumper;
alien[j++] = PhazerShooter;
alien[j++] = Recycler;
alien[j++] = Shielder;
alien[j++] = Subber;
//alien[j++] = Me;

alien[j++] = Houston; 
alien[j++] = ExchangePost; 
alien[j++] = RadarStation; 
//alien[j++] = Derrick; 
//alien[j++] = Converter; 
alien[j++] = PowerPlant; 
alien[j++] = NuclearPlant; 
alien[j++] = BotFactory; 
alien[j++] = RepairCenter; 
alien[j++] = PowerStation; 
alien[j++] = DefenseTower; 
alien[j++] = PowerCaptor; 
alien[j++] = AutoLab; 
alien[j++] = ResearchCenter; 

errmode(0);
object item;
point dustbin; // position where wasps collect stolen items
dustbin.x = 34;
dustbin.y = 240;

while(true)
{
if (this.load != null) // when holding something
{
jet(1);
while (distance(position, dustbin) > 30)
{
turn (direction(dustbin));
fly();
}
drop();
}

item = radar(alien, 0, 360, 0, 10000, FilterOnlyLanding);
if (item != null) // can destroy something
{
Fight();
Steal();
}
           
else // nothing to destroy
{
Steal();
}
       
GoBack();    
continue;    
}
}


What do your thing about it?


Messages In This Thread
Natural Wasp - by krakers - 12-08-2015, 11:42 PM
RE: Natural Wasp - by RaptorParkowsky - 12-09-2015, 12:47 PM
RE: Natural Wasp - by krakers - 12-09-2015, 02:34 PM
RE: Natural Wasp - by True Destroyer - 12-10-2015, 01:26 AM
RE: Natural Wasp - by krakers - 12-15-2015, 02:43 AM
RE: Natural Wasp - by krakers - 08-01-2016, 06:48 PM
RE: Natural Wasp - by tomangelo - 08-01-2016, 08:21 PM
RE: Natural Wasp - by krakers - 08-02-2016, 09:00 AM
RE: Natural Wasp - by krakers - 08-09-2016, 11:53 AM
RE: Natural Wasp - by Smok - 08-10-2016, 10:34 PM
RE: Natural Wasp - by krakers - 08-11-2016, 09:51 PM
RE: Natural Wasp - by LRV - 10-21-2016, 08:34 AM
RE: Natural Wasp - by krakers - 12-26-2016, 01:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)