Empty variable for Triggering

Discussions about Coding and Scripting
Post Reply
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Empty variable for Triggering

Post by Barbie »

I found a strange piece of code in stock definition of the functions Decoration.skinnedFrag and Decoration.Frag:

Code: Select all

simulated function skinnedFrag(class<fragment> FragType, texture FragSkin, vector Momentum, float DSize, int NumFrags)  {
local int i;
local actor A, Toucher;
local Fragment s;

	if ( bOnlyTriggerable )
		return; 
	if (Event!='')
		foreach AllActors( class 'Actor', A, Event )
			A.Trigger( Toucher, pawn(Toucher) );
[...]
}
Why didn't use the coder simply "A.Trigger(None, None)" instead of passing an empty variable "Toucher" there?
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Empty variable for Triggering

Post by PrinceOfFunky »

That variable probably was needed for something else before and the coder forgot to "undeclare" it.
Or, the coder was not a good coder.
Or something out of my knowledge :D
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Empty variable for Triggering

Post by sektor2111 »

PrinceOfFunky wrote:That variable probably was needed for something else before and the coder forgot to "undeclare" it.
Or, the coder was not a good coder.
Or something out of my knowledge :D
:loool: :confused2:
Barbie wrote:Why didn't use the coder simply "A.Trigger(None, None)" instead of passing an empty variable "Toucher" there?
If both are None is not the same thing ? Aside, study Instigator related problems. Some of these decos might trigger a creature if I'm not mistaking and then creature is intended to react accordingly (alarms, start patrol, first hate, etc.) transmitted from player VIA decoration, If we have a default NONE, creature will not do mission. What I'm saying ? People actually don't know to setup a monster in other way than doing NOTHING in map... it's more simple to draw some cubes and put decos able to trigger a monster and go shoot them, even if monster cannot see that, do check monster's reaction.
Just use ReplaceFunction and see some SP maps no longer working properly, is not hard to a morph a map in trash using coding.
The problem of <SkinnedFrag> is not there anyway... The strange code is bellow that, and will have a better functionality this way:

Code: Select all

	for (i=0 ; i<NumFrags ; i++) 
	{
		s = Spawn( FragType, Owner); //TRY SPAWN - YES it's ONLY a try because we do have <i> pieces.
		if (s != None) //DID <i> SPAWN THIS TIME ? If Yes set values else will set nothing to None.
		{ //EACH SPAWN IN THIS GAME SHOULD BE CHECKED IF DID HAPPEN BEFORE MOOING VALUES.
			s.CalcVelocity(Momentum/100,0); //else err #1
			s.Skin = FragSkin; //#2
			s.DrawScale = DSize*0.5+0.7*DSize*FRand(); //#3
		}
	}
There were 3 Accessed None types in SkinnedFrag which I don't have anymore.
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Empty variable for Triggering

Post by Barbie »

sektor2111 wrote:There were 3 Accessed None types in SkinnedFrag
That was the reason initially why I had a look there. :wink:
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Post Reply