Invisible script bug

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Invisible script bug

Post by <LT>YosemiteSam[NL] » April 9th, 2011, 2:01 pm

I used the invisible script wich rezil and iznogod made but I get this strange bug when you are invisible. This is what happends;

first;
- you become invisible
- when invisible you can't die ! (you get hurt but your health then isn't 100 or 0 but (depending on how much you get hurt)-999....a bit like godmode)
- after you become visible again you still can't die.

second;
- you become invisible
- when invisible you can't die !
- when you don't get hurt while invisible and you become visible again you can die and everything is back to normal.

this is the code;

Code: Select all

invisible() //only call this thread
//dont call any other threads, this one handles everything


{
   thread waitforconnect();
   thread monitortrig();
}

waitforconnect()
{
   for(;;)
   {
      level waittill("connecting",player);
      player thread waitforspawn();
   }
}

waitforspawn()
{
   self endon("disconnect");
   self.isInv=false;
   for(;;)
   {
      self waittill("spawned");
      self.isInv=false;
   }
}

monitortrig()
{
   trigger=getent("invisible","targetname");
   fx = loadfx ("fx/dust/morpheus_spawnarmorinvis.efx");
   invissound = getent("invisible_sound","targetname");
   for(;;)
   {
     trigger waittill("trigger",user);
     if(!user.isInv)
     {
	 user.isInv=true;
	 user iprintln("^2 You have invisibility");
         user thread makeinvisible(45);
		 user playsound("invisibility");
	 wait 120;
	 invissound playsound("spawnsound");
	 playfx (fx, (-100,-996,224));
	 
	 }
   }
}

makeinvisible(time)
{
   self endon("disconnect");
   self endon("killed_player");
   self endon("spawned");
   
   self detachall();
   self setmodel("");

   wait time;
   
   self.isInv=false;

   if(!isdefined(self.pers["savedmodel"]))
      maps\mp\gametypes\_teams::model();
   else
      maps\mp\_utility::loadModel(self.pers["savedmodel"]);
	self iprintln("^2 Invisibility has worn off");
I tried alot of things but can't get it to work properly.

I also turned off the armor script iznogod made but to no avail.

Maybe awe is f*cking things up but I turned it off on the morpheus map.

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Invisible script bug

Post by <LT>YosemiteSam[NL] » April 9th, 2011, 4:17 pm

I just found this out aswell.
If I type "kill" in console while I'm invisible, you also do not die :shock:

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Invisible script bug

Post by Drofder2004 » April 9th, 2011, 5:35 pm

My guess would be the "detachall" function is actually detaching the part of you which considers health and death.

While detatched, if you receive damage you probably go into "negative health". Once you become visisble again (and your body reattached) you will again receive damage, but because you have surpassed "0 health" you just don't die...

This is a simple theory, not factual.

You could enter some "iprintln" functions in before and after being invisible

iprintln(self.health);

and see what comes up during this period.
A fix would probably be a new variable that monitors the damage you take while invisible and if it reaches '0' then it will make you visisble and kill you or when you reappear, remove that total from your health...

[Again, theorycrafting for code]
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Invisible script bug

Post by <LT>YosemiteSam[NL] » April 9th, 2011, 6:46 pm

Drofder2004 wrote:My guess would be the "detachall" function is actually detaching the part of you which considers health and death.

While detatched, if you receive damage you probably go into "negative health". Once you become visisble again (and your body reattached) you will again receive damage, but because you have surpassed "0 health" you just don't die...

This is a simple theory, not factual.

You could enter some "iprintln" functions in before and after being invisible

iprintln(self.health);

and see what comes up during this period.
A fix would probably be a new variable that monitors the damage you take while invisible and if it reaches '0' then it will make you visisble and kill you or when you reappear, remove that total from your health...

[Again, theorycrafting for code]
That's exactly what happends. I have the armorcode from Iznogod running and that prints your health on screen so I see that the health is going into the negatives.

I tried "if (self.health <= 0) self ("kill");" but that doesn't seem to work in this code.
Now I think I'll just put a line after you become visible which sets your health back to 100 (iow makes you dieable(?) again)
But that's not realy the way I wanna go, unfortunately my only choice :?

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Invisible script bug

Post by <LT>YosemiteSam[NL] » April 9th, 2011, 7:15 pm

I want to put some lines in which check your health during the wait time. How do I do that ?
Tried this;

Code: Select all

makeinvisible(time)
{
   self endon("disconnect");
   self endon("killed_player");
   self endon("spawned");
      
   self detachall();
   self setmodel("");

   wait time;
 {
 while(1)
 if (self.health <= 0)
 self.isinv=false;
 self.health = 100;
 }
   self.isInv=false;

   if(!isdefined(self.pers["savedmodel"]))
      maps\mp\gametypes\_teams::model();
   else
      maps\mp\_utility::loadModel(self.pers["savedmodel"]);
	self iprintln("^2 Invisibility has worn off");
But that don't work

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Invisible script bug

Post by Rezil » April 9th, 2011, 8:45 pm

Seperate thread, ran on all players:

Code: Select all

invHealth()
{
	for(;;)
	{
		if(self.health<=0) 
		{
			self.isInv = false;
			self.health = 100; //I doubt this fixes the problem
			self suicide();
		}
		wait 0.1;
	}
}
I believe your problem is somewhere else. I ran getAllTags() or something simmilar on a playermodel and the only tag I got was "", to which two models are attached, a head and a hat. So either IW are idiots and store game data based on playermodel(something that is irrelevant to health) or one of the tags is fucking it up. You could try reattaching the tags one by one and checking if Drof's theory is true. But for that my original script would've been more suited. Also, no need for a new variable if health is being depleted whether invisible or not, just use the above code.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Invisible script bug

Post by Drofder2004 » April 10th, 2011, 12:10 am

The idea that simply taking damage making the person invulnerable after becoming visisble is the only concern, does a small amount of dmg from a low fall case invulnerability, or only when a player hits the negatives?

If only when a player reaches negative health is the player invulnerable to death, then Rez's code should fix it.
I ran getAllTags() or something simmilar on a playermodel
The player model may have tags, but does the player themselves have hidden tags (e.g a hitbox). Potentially the health is directly connected with the player as a tag?

If something like this was the case, would "x.health" always be the players health?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Invisible script bug

Post by <LT>YosemiteSam[NL] » April 10th, 2011, 12:23 am

Woohoo !!!! Thx rez. and Drof mainly cause of the last code I've got it working now.
Script is now as follows;

Code: Select all

invisible() //only call this thread
//dont call any other threads, this one handles everything


{
   thread waitforconnect();
   thread monitortrig();
   
}

waitforconnect()
{
   for(;;)
   {
      level waittill("connecting",player);
      player thread waitforspawn();
   }
}

waitforspawn()
{
   self endon("disconnect");
   self.isInv=false;
   for(;;)
   {
      self waittill("spawned");
      self.isInv=false;
   }
}

monitortrig()
{
   trigger=getent("invisible","targetname");
   fx = loadfx ("fx/dust/morpheus_spawnarmorinvis.efx");
   invissound = getent("invisible_sound","targetname");
   for(;;)
   {
     trigger waittill("trigger",user);
     if(!user.isInv)
     {
	 user.isInv=true;
	 user iprintln("^2 You have invisibility");
         user thread makeinvisible(45);
		 user playsound("invisibility");
	 wait 120;
	 invissound playsound("spawnsound");
	 playfx (fx, (-100,-996,224));
	 
	 }
   }
}

makeinvisible(time)
{
   self endon("disconnect");
   self endon("killed_player");
   self endon("spawned");
   self endon("suicide");
   
   self detachall();
   self setmodel("");

   thread invHealth();
   
   wait time;
  
   self.isInv=false;

   if(!isdefined(self.pers["savedmodel"]))
      maps\mp\gametypes\_teams::model();
   else
      maps\mp\_utility::loadModel(self.pers["savedmodel"]);
	self iprintln("^2 Invisibility has worn off");
	
}

invHealth()
{
   for(;;)
   {
      if(self.health <= 0) 
      {
         self.health = 100;
         self suicide();
         self.isInv=false;

   if(!isdefined(self.pers["savedmodel"]))
      maps\mp\gametypes\_teams::model();
      else
      maps\mp\_utility::loadModel(self.pers["savedmodel"]);
      }
      wait 0.1;
   }
}
The player now dies and becomes visible when he gets more than 100 damage .... while being visible.
The savemodel and loadmodel lines I've added are essential, without them the player dies when he becomes visible again (after the set wait time that is) not while being visible.

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Invisible script bug

Post by Rezil » April 10th, 2011, 12:25 am

Glad it's fixed. And try to do as much debugging as possible, there may still be issues with it.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Invisible script bug

Post by <LT>YosemiteSam[NL] » April 10th, 2011, 12:49 am

Rezil wrote:Glad it's fixed. And try to do as much debugging as possible, there may still be issues with it.
:) no doubt, I'll test it on my own dedicated server and log in with my other 2 pc's .... if that is ok than I'll beta test the whole map on my friends server playing with 8 people.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Invisible script bug

Post by Drofder2004 » April 10th, 2011, 3:20 am

A few problems, you are not killing your infinite looped thread. and the looped thread is not relating to the player correctly. I have (hopefully, correctly) change the code to be more efficient and error free.

Change your code to:

Code: Select all

invHealth(time)
{
   for(i=0;i<time;i++)
   {
      if(self.health <= 0)
      {
         self.health = 100;
         self suicide();
         self.isInv=false;

         if(!isdefined(self.pers["savedmodel"]))
            maps\mp\gametypes\_teams::model();
         else
            maps\mp\_utility::loadModel(self.pers["savedmodel"]);

         break;
      }
      wait 1;
   }
}
And you also need to change to:

Code: Select all

SELF invHealth(time);
Also, remove the line

Code: Select all

wait time;
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Invisible script bug

Post by <LT>YosemiteSam[NL] » April 10th, 2011, 11:04 am

Ok thx Drof I'll try that.

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Invisible script bug

Post by <LT>YosemiteSam[NL] » April 15th, 2011, 10:25 am

FYI
I didn't change the script to your script drof and the server crashed after 19 minutes in my map due to "too many variables".
I'll change the script tonight and test it. I'll keep you posted.

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Invisible script bug

Post by IzNoGoD » April 15th, 2011, 11:54 am

Just edit the callback_playerdamage to end invisibility after taking damage that would otherwise make your health go below 0.
LMGTFY!

Its not a glitch... Its the future!

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Invisible script bug

Post by <LT>YosemiteSam[NL] » April 15th, 2011, 8:54 pm

Ok Drof I changed the code and now it's like this;

Code: Select all

invisible() //only call this thread
//dont call any other threads, this one handles everything


{
   thread waitforconnect();
   thread monitortrig();
   
}

waitforconnect()
{
   for(;;)
   {
      level waittill("connecting",player);
      player thread waitforspawn();
   }
}

waitforspawn()
{
   self endon("disconnect");
   self.isInv=false;
   for(;;)
   {
      self waittill("spawned");
      self.isInv=false;
   }
}

monitortrig()
{
   trigger=getent("invisible","targetname");
   fx = loadfx ("fx/dust/morpheus_spawnarmorinvis.efx");
   invissound = getent("invisible_sound","targetname");
   for(;;)
   {
     trigger waittill("trigger",user);
     if(!user.isInv)
     {
	 user.isInv=true;
	 user iprintln("^2 You have invisibility");
         user thread makeinvisible(45);
		 user playsound("invisibility");
	 wait 150;
	 invissound playsound("spawnsound");
	 playfx (fx, (-100,-996,224));
	 
	 }
   }
}

makeinvisible(time)
{
   time = 45;
   self endon("disconnect");
   self endon("killed_player");
   self endon("spawned");
   self endon("suicide");
   
   self detachall();
   self setmodel("");

   self invHealth(time);
   
   //wait time;
  
   self.isInv=false;

   if(!isdefined(self.pers["savedmodel"]))
      maps\mp\gametypes\_teams::model();
   else
      maps\mp\_utility::loadModel(self.pers["savedmodel"]);
	self iprintln("^2 Invisibility has worn off");
	
}

invHealth(time)
{
   for(i=0;i<time;i++)
   {
      if(self.health <= 0) 
      {
         self.isInv=false;
		 self.health = 100;
         self suicide();
		 

      if(!isdefined(self.pers["savedmodel"]))
      maps\mp\gametypes\_teams::model();
      else
      maps\mp\_utility::loadModel(self.pers["savedmodel"]);
      
	  break;
	  
	  }
      wait 1;
   }
}
I added the "time = 45;" otherwise you won't be invisible for the set amount of time.
The problem now is the same as before.... you can't die. When you get over 100 damage you are visible and go to 0 health (= suicide) but the "self.health = 100;" line doesn't seem to work anymore.

*EDIT* if I remove the "break;" line it works again, but can the script still crash the server due to too many variables ?

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests