Author Topic: Trigger attached to a player || setRelativeVelocity || life in general  (Read 1041 times)

Hey guys, I'm making a thing where you can have different auroras around you, and the people within that area experience different effects. When I first tried something like this a long while ago, I just did a containerRadiusSearch starting from the player's position. The problem with this is that the player can move away, and the aurora will stay behind. Is there any way to make a trigger/zone/whatever that is always attached to the player's position?
« Last Edit: September 09, 2015, 12:16:54 AM by Johnny Blockhead »

A trigger cannot be attached to something. They're also limited to non-rotatable cuboids.
It's best if you just do radius searches on a loop.

They're also limited to non-rotatable cuboids.
You can freely rotate triggers on any axis.

containerRadiusSearch starting from the player's position.
use the player's current position instead of the starting position and it should be fine?

use the player's current position instead of the starting position and it should be fine?

"starting from the player's position" != "from the player's starting position"


But yeah, put it on a loop, and make the effect only last for a set amount of time.

-nvm i should post this in modification help-
« Last Edit: September 06, 2015, 10:15:25 PM by Johnny Blockhead »

Okay, new new question. I want to set the relative velocity of a player by 10 in the direction they are looking. I remember doing this before, but I can't remember how. For reference, addRelativeVelocity reads:
function Player::addRelativeVelocity(%player,%xyz)
{
   %x = getWord(%xyz,0);
   %y = getWord(%xyz,1);
   %z = getWord(%xyz,2);
   %forwardVector = %player.getForwardVector();
   %forwardX = getWord(%forwardVector,0);
   %forwardY = getWord(%forwardVector,1);
   %player.addVelocity((%x * %forwardY + %y * %forwardX) SPC (%y * %forwardY + %x * -%forwardX) SPC %z);
}

Okay, new new question. I want to set the relative velocity of a player by 10 in the direction they are looking.

You're over complicating it.

%player.setVelocity(vectorScale(%player.getEyeVector(), 10));


Also, in the future, if you're asking an entirely new question, make a new topic. Only re-use old topics if the question is similar.

Also, in the future, if you're asking an entirely new question, make a new topic. Only re-use old topics if the question is similar.
It really doesn't matter, as long as you're not editing for OP for it.

Thanks boodals, it worked. I just didn't want it so that they could aim up and take off like a rocket ship, so I did this:
%client.abilityOneCD = $Sim::Time + 2;
%vec = vectorScale(%client.player.getEyeVector(), 100);
%x = getWord(%vec,0);
%y = getWord(%vec,1);
%client.player.setVelocity(%x SPC %y SPC 2);
%client.player.schedule(300, setVelocity, "0 0 0");

I'm not exactly sure what to do with the topics situation, if I made a new one every time I would feel like I'd be spamming. In the past people have advised me to not edit the OP, but change the title.

--

Small question, if I wanted to change a variable on a schedule, how'd I go about doing that? Basically I have %client.isAdrenalineMode set to one, but when it wears off I want it to be set to 0. Is there a way to do this without creating a special function for it?
« Last Edit: September 07, 2015, 11:45:04 AM by Johnny Blockhead »

Small question, if I wanted to change a variable on a schedule, how'd I go about doing that? Basically I have %client.isAdrenalineMode set to one, but when it wears off I want it to be set to 0. Is there a way to do this without creating a special function for it?
You'd either have to create a special function for it, or use eval(people seem to hate it when you use it though, even when there's no way for it to be exploited). Like so: schedule(%time, 0, eval, %client @ ".isAdrenalineMode = 0;"); %time is in milliseconds. You can replace the 0 with an object if you want it to not run if the object no longer exists when the time is up.

You'd either have to create a special function for it, or use eval(people seem to hate it when you use it though, even when there's no way for it to be exploited). Like so: schedule(%time, 0, eval, %client @ ".isAdrenalineMode = 0;"); %time is in milliseconds. You can replace the 0 with an object if you want it to not run if the object no longer exists when the time is up.
As far as I've heard, it's an efficiency issue.
You could just include this function.

Code: [Select]
function SimObject::setAttribute(%this, %attr, %value)
{
   if (%attr $= "")
      return;

   switch (stripos("_abcdefghijklmnopqrstuvwxyz", getSubStr(%attr, 0, 1)))
   {
      case  0: %this._[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  1: %this.a[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  2: %this.b[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  3: %this.c[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  4: %this.d[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  5: %this.e[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  6: %this.f[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  7: %this.g[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  8: %this.h[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case  9: %this.i[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 10: %this.j[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 11: %this.k[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 12: %this.l[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 13: %this.m[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 14: %this.n[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 15: %this.o[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 16: %this.p[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 17: %this.q[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 18: %this.r[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 19: %this.s[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 20: %this.t[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 21: %this.u[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 22: %this.v[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 23: %this.w[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 24: %this.x[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 25: %this.y[getSubStr(%attr, 1, strlen(%attr))] = %value;
      case 26: %this.z[getSubStr(%attr, 1, strlen(%attr))] = %value;
   }
}
Then call %client.schedule(time,setAttribute,"isAdrenalineMode",0);

Thanks boodals, it worked. I just didn't want it so that they could aim up and take off like a rocket ship, so I did this:
There's one small issue I see here.
getEyeVector returns a normalized vector, that is, it will always be of length of 1.
But when you cut off the Z part, you cut off part of that length, leaving you with a vector that will have a length of 1 if the player is looking straight ahead, but falling off to 0 as they look straight up or down
Use VectorNormalize to normalize the vector with Z cut off back to length 1, and then VectorScale the normalized vector

Thanks guys! I've run into numerous different issues. The first one is that I want to destroy all placed robots/teleporters/ect if the mini game is restarted or ended using Slayer. Is adding them all to a scriptGroup and deleting them when the round ends the way to go about this? Also what are the functions I should package for restarting or round ending? One of the abilities people have is to create a bomb at their position. How'd I get it to discriminate who it hurts through slayer teams? Do I assign a client to it? The way it's coded is that an item is placed, then on a schedule it is deleted and an explosion is spawned at that position. Another thing I'm wondering is how do you properly transfer items from a player object to another? There's a feature where you can build a robot, then control it from afar. Do I just set the tool1/tool2/ect equal to eachother? Sorry I wrote this on a phone and I can't test a lot of this stuff.

edit: figured all of this stuff on my own
« Last Edit: September 12, 2015, 04:44:01 PM by Johnny Blockhead »