Access Nones caused by Spawnpoint

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

Access Nones caused by Spawnpoint

Post by Barbie »

Just FYI a story of my work on MonsterHunt: Recently I was looking for the reason of a lot of "Access Nones" in the log:
ucc.init.log
Devilfish MH-FightOn.Devilfish1 (Function UnrealShare.ScriptedPawn.SetEnemy:0029) Accessed None
Devilfish MH-FightOn.Devilfish1 (Function UnrealShare.ScriptedPawn.SetEnemy:0031) Accessed None
Devilfish MH-FightOn.Devilfish3 (Function UnrealShare.ScriptedPawn.SetEnemy:0029) Accessed None
Devilfish MH-FightOn.Devilfish3 (Function UnrealShare.ScriptedPawn.SetEnemy:0031) Accessed None
Devilfish MH-FightOn.Devilfish5 (Function UnrealShare.ScriptedPawn.SetEnemy:0029) Accessed None
Devilfish MH-FightOn.Devilfish5 (Function UnrealShare.ScriptedPawn.SetEnemy:0031) Accessed None
Devilfish MH-FightOn.Devilfish6 (Function UnrealShare.ScriptedPawn.SetEnemy:0029) Accessed None
Devilfish MH-FightOn.Devilfish6 (Function UnrealShare.ScriptedPawn.SetEnemy:0031) Accessed None
and dozens more... BTW I noticed that some Devilfishes (eg "Devilfish2") does not cause a problem
I tested it by adding some DevilFishes in a pool and playing around with them in a test map, but - no log warnings. :shock:
Then I removed the fishes and added a CreatureFactory that produces DevilFishes: bingo. :P
A closer look at the SpawnPoint code that creates the factories' prototype lead my attention to this line

Code: Select all

function bool Create() {
[...]
	ScriptedPawn(newcreature).SetEnemy(pawnFactory.enemy);
[...]
where the enemie is set for that new Pawn. But ScriptedPawn.SetEnemy() does not handle the case correctly if NewEnemy is None:

Code: Select all

01 function bool SetEnemy( Pawn NewEnemy )
02 {
03 	local bool result;
04 	local eAttitude newAttitude, oldAttitude;
05 	local bool noOldEnemy;
06 	local float newStrength;
07 
08 	if ( !bCanWalk && !bCanFly && !NewEnemy.FootRegion.Zone.bWaterZone )
09 		return false;
10 	if ( (NewEnemy == Self) || (NewEnemy == None) || (NewEnemy.Health <= 0) )
11 		return false;
NewEnemy is accessed in line 8 ("NewEnemy.FootRegion") before it is checked for None in line 10 and this causes the Access Nones for ScriptedPawns that cannot walk nor fly.
So the actual problem is in ScriptedPawn.SetEnemy(), not in SpawnPoint.Create().

My solution for the Pawns created by a factory was easy, because I've substituted the Thing- and CreatureFactories by my own versions already, and now they create their prototypes by themselves - SpawnPoint.Create() isn't used any more.


But one question remains for me: why were there two Accessed None per DevilFish? The function SetEnemie returns in line 11 after evaluation of (NewEnemy == None), which should be TRUE there...
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Access Nones caused by Spawnpoint

Post by sektor2111 »

I get over this by using another "fish". Set enemy is wrong done there. Pawn can see you, wants to attack, but SetEnemy is messing up with Water needs. I totally removed that line because is a nonsense in a New Function not called as default, as long as I'm using friendly creatures with rules changed. Example they can play MH because are team 3 and attack everything out of their team in this "bTeamGame", else if they go in CTF with Team 1, will not attack blues and so on, more compatible with a team attitude. If we have a "bTeamGame=False" they attack everything which moves visible, marked visible because they won't be interested by hidden pawns (spectators), pawns pending removal, pawns with no mesh to hit, etc. So you can improve things easily by using other "monsters". When I did new stock ScriptedPawns imagine that I was aiming 3 goals: CTF DM MH (oops 4, MA too), and this way almost all troubles went away.
Post Reply