Please or Register to create posts and topics.

Easter egg in the frankenturret intro!

PreviousPage 2 of 2

How did you manage to do that?

My stuff:
[spoiler]- BEE2 Addons | (BEE2)
- Hammer Addons
Maps:
- Crushed Gel
- Gel is Not Always Helpful[/spoiler]

It wasn't hard, I'll post my code. Basically I would slowly turn them towards the most interesting thing they could see each time they hopped.

Script follows...

Spoiler

Code: Select all
// Sentient Turret Cube Script
// Includes some code from Sicklebrick (sicklebrick.com)'s "spinner.nut" script.

pickedup <- false;
boxed <- false;
target <- null;
counter <- 0;
turning <- 0;
maxturn <- 30;
disabled <- false; // A general-purpose flag that's currently unused.

EntFireByHandle( self, "AddOutput", "OnPhysGunPickup !self,runscriptcode,PickedUp()", 0 , null, null);
EntFireByHandle( self, "AddOutput", "OnPhysGunDrop !self,runscriptcode,Dropped()", 0 , null, null);
EntFireByHandle(self,"RunScriptFile","fg/libs/vector_math.nut",0.0,null,null);

function PickedUp(){
   pickedup = true;
}

function Dropped(){
   pickedup = false;
}

function Think(){
//   if(counter <= 100){counter++;}else{aim();counter-=100;}
   EntFireByHandle(self,"RunScriptCode","Think();",5.0,null,null);
   if(disabled) return;
   aim();
   track();
}

function box(){
   if(disabled) return;
   EntFireByHandle(self,"BecomeBox","",0.0,null,null);
   boxed = true;
}

function unbox(){
   if(disabled == true) return;
   EntFireByHandle(self,"BecomeMonster","",0.0,null,null);
   boxed = false;
//   disabled = true;
//   EntFireByHandle(self,"RunScriptCode","disabled = false;",1.0,null,null);
}

function turn(target_yaw){
   if(disabled == true) return;
   delta <- target_yaw - self.GetAngles().y;
   if(delta >=  180) delta -= 360;
   if(delta <= -180) delta += 360;
   delta /= maxturn;
   turning <- maxturn;
   ThinkTurn();
}

function ThinkTurn(){
   local ang = self.GetAngles();
   self.SetAngles(ang.x, ang.y+delta, ang.z);
   turning--;
   if(turning != 0) EntFireByHandle(self,"RunScriptCode","ThinkTurn();",1.0/maxturn,null,null);
}

function interest(entity){   
   if(entity == null) return -1;
   
   if(IsMultiplayer() ? (entity.GetName == "blue" || entity.GetName == "red") : entity == GetPlayer()) return 10; // Players are very interesting!
   
   if(entity.GetClassname() == "prop_floor_button") return (entity.GetTeam() == 0 ? 5 : 2); // Buttons are interesting if they aren't pressed already.
   
   if((entity.GetClassname() == "prop_testchamber_door" || entity.GetClassname() == "prop_linked_portal_door" || entity.GetClassname() == "linked_portal_door") && entity.GetTeam == 1) return 7; // Doors are interesting if they're open.
   
   if(entity.GetClassname() == "npc_portal_turret_floor") return 6; // Turrets are interesting!
   
   if(entity.GetClassname() == "trigger_portal_cleanser") return 2; // Fizzlers are interesting, sadly.
   
   if(entity.GetClassname() == "func_clip_vphysics") return 3; // Blockfields are more interesting.
   
   if(entity.GetClassname() == "prop_tractor_beam") return 6.5; // Tbeams are pretty interesting.
   
   if(entity.GetClassname() == "prop_monster_box" && entity != self) return 5.5; // Other boxes are sort of interesting.
   
   return 0;
}

function aim(){
   if(disabled == true) return;
   printl("TURRETCUBE: Aiming");
   target = null;
   local intr;
   local dist;
   local closest = 0;
   local mostInteresting = 0;
   local poi = null;
   
   do{
      target = Entities.FindInSphere(target, self.GetOrigin(), 256.0);
      if(target == null){
         break; // This should never happen!
      }
//      printl("TURRETCUBE: Found something!");
      dist = vector_length(target.GetOrigin() - self.GetOrigin());
      intr = interest(target);
//      printl("TURRETCUBE: It's "+intr);
      if(intr > mostInteresting){
//         printl("TURRETCUBE: It's my new target! It's more interesting!");
         mostInteresting = intr;
         closest = dist;
         poi = target;
      }else if(intr == mostInteresting && dist < closest){
//         printl("TURRETCUBE: It's my new target! It's closer!");
         mostInteresting = intr;
         closest = dist;
         poi = target;
      }
   }while(target != null);
   
   target = poi;
   if(target == null){
//      printl("TURRETCUBE: Nothing nearby, shutting down.");
      box();
      return;
   }
//   printl("TURRETCUBE: Decided on "+target.GetName()+" ("+target.GetClassname()+")");
   unbox();
}

function track(){
   if(disabled == true) return;
   if (target != null && pickedup == false && boxed == false){
      ppos <- target.GetCenter();
      mpos <- self.GetCenter();
      ang <- self.GetAngles();

      dx <- ppos.x - mpos.x;
      dy <- ppos.y - mpos.y;
//      dz <- ppos.z - mpos.z;
      
      yaw <- atan2(dy, dx ) * 180 / 3.14159265;
   
//      dist <- sqrt( (dx * dx) + (dy * dy) );
//      pitch <- atan2( dz , dist ) * 180 / 3.14159265 * -1
      
      turn(yaw);
   }
}

Falsi sumus crusto!

This thing can be done in cubes for the noobs (I don't know the actual name) the Frankenstein turret will go through the lasers,hence,deactivating the laser fields.

Game mapper.





[spoiler]not really[/spoiler]
FelixGriffin wrote:
It wasn't hard, I'll post my code. Basically I would slowly turn them towards the most interesting thing they could see each time they hopped.

Script follows...

Spoiler

Code: Select all
// Sentient Turret Cube Script
// Includes some code from Sicklebrick (sicklebrick.com)'s "spinner.nut" script.

pickedup <- false;
boxed <- false;
target <- null;
counter <- 0;
turning <- 0;
maxturn <- 30;
disabled <- false; // A general-purpose flag that's currently unused.

EntFireByHandle( self, "AddOutput", "OnPhysGunPickup !self,runscriptcode,PickedUp()", 0 , null, null);
EntFireByHandle( self, "AddOutput", "OnPhysGunDrop !self,runscriptcode,Dropped()", 0 , null, null);
EntFireByHandle(self,"RunScriptFile","fg/libs/vector_math.nut",0.0,null,null);

function PickedUp(){
   pickedup = true;
}

function Dropped(){
   pickedup = false;
}

function Think(){
//   if(counter <= 100){counter++;}else{aim();counter-=100;}
   EntFireByHandle(self,"RunScriptCode","Think();",5.0,null,null);
   if(disabled) return;
   aim();
   track();
}

function box(){
   if(disabled) return;
   EntFireByHandle(self,"BecomeBox","",0.0,null,null);
   boxed = true;
}

function unbox(){
   if(disabled == true) return;
   EntFireByHandle(self,"BecomeMonster","",0.0,null,null);
   boxed = false;
//   disabled = true;
//   EntFireByHandle(self,"RunScriptCode","disabled = false;",1.0,null,null);
}

function turn(target_yaw){
   if(disabled == true) return;
   delta <- target_yaw - self.GetAngles().y;
   if(delta >=  180) delta -= 360;
   if(delta <= -180) delta += 360;
   delta /= maxturn;
   turning <- maxturn;
   ThinkTurn();
}

function ThinkTurn(){
   local ang = self.GetAngles();
   self.SetAngles(ang.x, ang.y+delta, ang.z);
   turning--;
   if(turning != 0) EntFireByHandle(self,"RunScriptCode","ThinkTurn();",1.0/maxturn,null,null);
}

function interest(entity){   
   if(entity == null) return -1;
   
   if(IsMultiplayer() ? (entity.GetName == "blue" || entity.GetName == "red") : entity == GetPlayer()) return 10; // Players are very interesting!
   
   if(entity.GetClassname() == "prop_floor_button") return (entity.GetTeam() == 0 ? 5 : 2); // Buttons are interesting if they aren't pressed already.
   
   if((entity.GetClassname() == "prop_testchamber_door" || entity.GetClassname() == "prop_linked_portal_door" || entity.GetClassname() == "linked_portal_door") && entity.GetTeam == 1) return 7; // Doors are interesting if they're open.
   
   if(entity.GetClassname() == "npc_portal_turret_floor") return 6; // Turrets are interesting!
   
   if(entity.GetClassname() == "trigger_portal_cleanser") return 2; // Fizzlers are interesting, sadly.
   
   if(entity.GetClassname() == "func_clip_vphysics") return 3; // Blockfields are more interesting.
   
   if(entity.GetClassname() == "prop_tractor_beam") return 6.5; // Tbeams are pretty interesting.
   
   if(entity.GetClassname() == "prop_monster_box" && entity != self) return 5.5; // Other boxes are sort of interesting.
   
   return 0;
}

function aim(){
   if(disabled == true) return;
   printl("TURRETCUBE: Aiming");
   target = null;
   local intr;
   local dist;
   local closest = 0;
   local mostInteresting = 0;
   local poi = null;
   
   do{
      target = Entities.FindInSphere(target, self.GetOrigin(), 256.0);
      if(target == null){
         break; // This should never happen!
      }
//      printl("TURRETCUBE: Found something!");
      dist = vector_length(target.GetOrigin() - self.GetOrigin());
      intr = interest(target);
//      printl("TURRETCUBE: It's "+intr);
      if(intr > mostInteresting){
//         printl("TURRETCUBE: It's my new target! It's more interesting!");
         mostInteresting = intr;
         closest = dist;
         poi = target;
      }else if(intr == mostInteresting && dist < closest){
//         printl("TURRETCUBE: It's my new target! It's closer!");
         mostInteresting = intr;
         closest = dist;
         poi = target;
      }
   }while(target != null);
   
   target = poi;
   if(target == null){
//      printl("TURRETCUBE: Nothing nearby, shutting down.");
      box();
      return;
   }
//   printl("TURRETCUBE: Decided on "+target.GetName()+" ("+target.GetClassname()+")");
   unbox();
}

function track(){
   if(disabled == true) return;
   if (target != null && pickedup == false && boxed == false){
      ppos <- target.GetCenter();
      mpos <- self.GetCenter();
      ang <- self.GetAngles();

      dx <- ppos.x - mpos.x;
      dy <- ppos.y - mpos.y;
//      dz <- ppos.z - mpos.z;
      
      yaw <- atan2(dy, dx ) * 180 / 3.14159265;
   
//      dist <- sqrt( (dx * dx) + (dy * dy) );
//      pitch <- atan2( dz , dist ) * 180 / 3.14159265 * -1
      
      turn(yaw);
   }
}

I love how you say that isn't hard :lol:, shows how experienced you are!

As for the cube's though, they shouldn't be able to trigger the button, there's a trigger around it which forces the cube from the "monster" state, to the "cube" state. Somehow the frankenturret glitched onto the button I guess :lol:

This Signature is Beyond Your Range of Seeing.

Image
PreviousPage 2 of 2