The_Cowboy wrote:Also I'd use
for conditional check.
This would return true even for child classes :/
sektor2111 wrote:Return True doesn't mean that "for" cycle is stopped, entire function might still have an out to be pointed and this I'm not sure will stop it just because has a return True - (log entire cycle ?), I think it will reach to the end because nothing breaks the cycle when target has been found. In such a cycle when you have found your actor target just break it, also there is no need for more iterations. In UE1 some times you will want another programing logic...
and then it will be
Code: Select all
...
return True;
break; //unless it will loop to the end
...
Also I must ask what are you doing with that "Actor actor" from parameters...
I thought about the function continuing to executing, that would have sense if the out parameter was set with an inventory found after the return statement, but the problem is that the out parameter is set with an inventory found before the return statement and before the last found one. I'll still try the break statement anyway.
This was the original flow, each screenshot is a different function:
- touch.jpg (9.87 KiB) Viewed 725 times
and these are the logs:
- log.jpg (49.37 KiB) Viewed 725 times
I know the function I wrote in the first post looks different from "hasInv()" but the result is the same, I already tried it.
EDIT: Just logged out this:
Maybe classIsRelatedTo() doesn't return anything even if firstClass is equal to secondClass... That sounds strange to me .o.
EDIT 2: Nvm it does. (I would post a screenshot but I reached the limit of 5 screenshots).
EDIT 3: I changed the code like this (it even skips classIsRelatedTo()):
Code: Select all
static function bool hasInv(Actor actor, class<Inventory> invClass, out Inventory inv, optional bool bNoSubclass) {
for (inv = actor.inventory; inv != None; inv = inv.inventory) {
Log(1);
Log("Before checking classes"@inv);
Log(2);
if (invClass == inv.Inventory.class) {
Log("Before returning true"@inv);
return true;
}
}
inv = None;
return false;
}
And these are the logs:
Code: Select all
ScriptLog: 123456789 Botpack.minigun2
ScriptLog: True False False 100 100
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.enforcer1
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.WarHeadAmmo0
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.WarheadLauncher1
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.ThighPads2
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.Armor0
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.RocketPack0
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.UT_Eightball0
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.BladeHopper0
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.ripper0
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.BulletBox0
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.SniperRifle0
ScriptLog: 2
ScriptLog: 1
ScriptLog: Before checking classes UR-HyperBlast.Miniammo0
ScriptLog: 2
ScriptLog: Before returning true UR-HyperBlast.Miniammo0
ScriptLog: ISTHISTHELOG? Botpack.minigun2 UR-HyperBlast.Miniammo0
So now, all of a sudden, it is not printing the minigun2 log? I don't get how it is possible to pass this check "invClass == inv.Inventory.class" with invClass=Botpack.minigun2 and inv.Inventory.class=Botpack.Miniammo...