Page 1 of 1

Grab array in actor, two different actors

Posted: Fri May 26, 2017 11:26 pm
by ANUBITEK
I have two actors that both have arrays that, if inserted, have 4 elements:

Code: Select all

struct Animations
{
	var array<BitMap> Stand;
	var array<BitMap> Walk;
	var array<BitMap> Jump;
	var array<BitMap> Run;
};
var private array<Animations> Sprites;
And they are in two actors (DummyAnimActor,RPG_PlatformPawn), the first is a subclass of Actor and the second is a subclass of playerpawn. I need a way to determine who my input actor is into a function, if it isn't either of these then return, but otherwise output these actors as a selected, in-game actor. But I need either of them to be under a catch-all actor title (a name or string, not sure honestly) and modify the array (Sprites).

Here is an idea for how to do this, is this going the right way?

Code: Select all

function DetermineActor(actor Target, out string targStr)
{
 if(Target == class<DummyAnimActor>) {targStr = string(Target);}
 else if(Target == class<RPG_PlatformPawn>) {targStr = string(Target);}
 [SANITY CHECKS ETC. GO HERE]
 return targStr;
}
I've read that typecasting an actor as a string will give me the package name.actor name[number] (eg. "RPG_Game_dev.DummyAnimActor0").

If I do this, the problem becomes typecasting back into a class and being able to do something like

Code: Select all

classTitle.Sprite[i].Walk[i]
because if I make classTitle "class<actor>" then I could get issues with not finding this array in class actor.

I'm working on a parser that goes through .int files to assign textures to these arrays for the directional sprite thing. I have most of that written, but this is the last piece before I can test it.

Re: Grab array in actor, two different actors

Posted: Sat May 27, 2017 1:35 am
by Chris
Dynamic arrays are not supported in UnrealScript 1, they are only exposable.

Re: Grab array in actor, two different actors

Posted: Sat May 27, 2017 2:46 am
by Barbie
Why don't you just use

Code: Select all

if (DummyAnimActor(Target) != None)
{
	// code for DummyAnimActor here
}
else if (RPG_PlatformPawn(Target) != None)
{
	// code for RPG_PlatformPawn here
}
else warn("Wrong target type=" $ target);
If you want to exclude sub classes from execution, use (Target.Class == Class'DummyAnimActor') as condition.

Re: Grab array in actor, two different actors

Posted: Sat May 27, 2017 4:39 am
by ANUBITEK
Chris wrote:Dynamic arrays are not supported in UnrealScript 1, they are only exposable.
Could you elaborate a bit? I've managed to insert up to 8 textures into at least one of those slots before (sprites[0].walk[0-7]) and created more than one array of sprites (sprites[0-7]) and in each of those stored a set of textures (sprites[0-7].walk[0-7]). That being said, I have not attempted to fill others (sprites[0-7].run/jump/stand[x]).

This is how I did it recently (and it worked, I have video):
Spoiler

Code: Select all

struct Animations
{
    var array<BitMap> CurrentSet;
	var array<BitMap> Stand;
	var array<BitMap> WalkForward;
	var array<BitMap> WalkForwardLeft;
	var array<BitMap> WalkForwardRight;
	var array<BitMap> WalkLeft;
	var array<BitMap> WalkRight;
	var array<BitMap> WalkBackLeft;
	var array<BitMap> WalkBackRight;
	var array<BitMap> WalkBack;
};
var private array<Animations> Sprites;
[...]
	//=============================================================================
	//Hardcoded frames (dynamic arrays should allow this kind of accessors)
	//=============================================================================
	Sprites[0].WalkForward[0] = Texture'RPG_Test_Sprite.DownWalk3';
	Sprites[0].WalkForward[1] = Texture'RPG_Test_Sprite.DownWalk4';
	Sprites[0].WalkForward[2] = Texture'RPG_Test_Sprite.DownWalk5';
	Sprites[0].WalkForward[3] = Texture'RPG_Test_Sprite.DownWalk6';
	Sprites[0].WalkForward[4] = Texture'RPG_Test_Sprite.DownWalk7';
	Sprites[0].WalkForward[5] = Texture'RPG_Test_Sprite.DownWalk8';
	Sprites[0].WalkForward[6] = Texture'RPG_Test_Sprite.DownWalk1';
	Sprites[0].WalkForward[7] = Texture'RPG_Test_Sprite.DownWalk2';

	Sprites[0].WalkForwardRight[0] = Texture'RPG_Test_Sprite.DownRightWalk3';
	Sprites[0].WalkForwardRight[1] = Texture'RPG_Test_Sprite.DownRightWalk4';
	Sprites[0].WalkForwardRight[2] = Texture'RPG_Test_Sprite.DownRightWalk5';
	Sprites[0].WalkForwardRight[3] = Texture'RPG_Test_Sprite.DownRightWalk6';
	Sprites[0].WalkForwardRight[4] = Texture'RPG_Test_Sprite.DownRightWalk7';
	Sprites[0].WalkForwardRight[5] = Texture'RPG_Test_Sprite.DownRightWalk8';
	Sprites[0].WalkForwardRight[6] = Texture'RPG_Test_Sprite.DownRightWalk1';
	Sprites[0].WalkForwardRight[7] = Texture'RPG_Test_Sprite.DownRightWalk2';
	
	Sprites[0].WalkRight[0] = Texture'RPG_Test_Sprite.RightWalk3';
	Sprites[0].WalkRight[1] = Texture'RPG_Test_Sprite.RightWalk4';
	Sprites[0].WalkRight[2] = Texture'RPG_Test_Sprite.RightWalk5';
	Sprites[0].WalkRight[3] = Texture'RPG_Test_Sprite.RightWalk6';
	Sprites[0].WalkRight[4] = Texture'RPG_Test_Sprite.RightWalk7';
	Sprites[0].WalkRight[5] = Texture'RPG_Test_Sprite.RightWalk8';
	Sprites[0].WalkRight[6] = Texture'RPG_Test_Sprite.RightWalk1';
	Sprites[0].WalkRight[7] = Texture'RPG_Test_Sprite.RightWalk2';
	
	Sprites[0].WalkBackRight[0] = Texture'RPG_Test_Sprite.UpRightWalk3';
	Sprites[0].WalkBackRight[1] = Texture'RPG_Test_Sprite.UpRightWalk4';
	Sprites[0].WalkBackRight[2] = Texture'RPG_Test_Sprite.UpRightWalk5';
	Sprites[0].WalkBackRight[3] = Texture'RPG_Test_Sprite.UpRightWalk6';
	Sprites[0].WalkBackRight[4] = Texture'RPG_Test_Sprite.UpRightWalk7';
	Sprites[0].WalkBackRight[5] = Texture'RPG_Test_Sprite.UpRightWalk8';
	Sprites[0].WalkBackRight[6] = Texture'RPG_Test_Sprite.UpRightWalk1';
	Sprites[0].WalkBackRight[7] = Texture'RPG_Test_Sprite.UpRightWalk2';
	
	Sprites[0].WalkBack[0] = Texture'RPG_Test_Sprite.UpWalk3';
	Sprites[0].WalkBack[1] = Texture'RPG_Test_Sprite.UpWalk4';
	Sprites[0].WalkBack[2] = Texture'RPG_Test_Sprite.UpWalk5';
	Sprites[0].WalkBack[3] = Texture'RPG_Test_Sprite.UpWalk6';
	Sprites[0].WalkBack[4] = Texture'RPG_Test_Sprite.UpWalk7';
	Sprites[0].WalkBack[5] = Texture'RPG_Test_Sprite.UpWalk8';
	Sprites[0].WalkBack[6] = Texture'RPG_Test_Sprite.UpWalk1';
	Sprites[0].WalkBack[7] = Texture'RPG_Test_Sprite.UpWalk2';

	Sprites[0].WalkBackLeft[0] = Texture'RPG_Test_Sprite.UpLeftWalk3';
    Sprites[0].WalkBackLeft[1] = Texture'RPG_Test_Sprite.UpLeftWalk4';
    Sprites[0].WalkBackLeft[2] = Texture'RPG_Test_Sprite.UpLeftWalk5';
    Sprites[0].WalkBackLeft[3] = Texture'RPG_Test_Sprite.UpLeftWalk6';
    Sprites[0].WalkBackLeft[4] = Texture'RPG_Test_Sprite.UpLeftWalk7';
	Sprites[0].WalkBackLeft[5] = Texture'RPG_Test_Sprite.UpLeftWalk8';
    Sprites[0].WalkBackLeft[6] = Texture'RPG_Test_Sprite.UpLeftWalk1';
	Sprites[0].WalkBackLeft[7] = Texture'RPG_Test_Sprite.UpLeftWalk2';
	
	Sprites[0].WalkLeft[0] = Texture'RPG_Test_Sprite.LeftWalk3';
	Sprites[0].WalkLeft[1] = Texture'RPG_Test_Sprite.LeftWalk4';
	Sprites[0].WalkLeft[2] = Texture'RPG_Test_Sprite.LeftWalk5';
	Sprites[0].WalkLeft[3] = Texture'RPG_Test_Sprite.LeftWalk6';
	Sprites[0].WalkLeft[4] = Texture'RPG_Test_Sprite.LeftWalk7';
	Sprites[0].WalkLeft[5] = Texture'RPG_Test_Sprite.LeftWalk8';
	Sprites[0].WalkLeft[6] = Texture'RPG_Test_Sprite.LeftWalk1';
	Sprites[0].WalkLeft[7] = Texture'RPG_Test_Sprite.LeftWalk2';
	
	Sprites[0].WalkForwardLeft[0] = Texture'RPG_Test_Sprite.DownLeftWalk3';
	Sprites[0].WalkForwardLeft[1] = Texture'RPG_Test_Sprite.DownLeftWalk4';
	Sprites[0].WalkForwardLeft[2] = Texture'RPG_Test_Sprite.DownLeftWalk5';
	Sprites[0].WalkForwardLeft[3] = Texture'RPG_Test_Sprite.DownLeftWalk6';
	Sprites[0].WalkForwardLeft[4] = Texture'RPG_Test_Sprite.DownLeftWalk7';
	Sprites[0].WalkForwardLeft[5] = Texture'RPG_Test_Sprite.DownLeftWalk8';
	Sprites[0].WalkForwardLeft[6] = Texture'RPG_Test_Sprite.DownLeftWalk1';
	Sprites[0].WalkForwardLeft[7] = Texture'RPG_Test_Sprite.DownLeftWalk2';
//===========================================================================
Barbie wrote:Why don't you just use

Code: Select all

if (DummyAnimActor(Target) != None)
{
	// code for DummyAnimActor here
}
else if (RPG_PlatformPawn(Target) != None)
{
	// code for RPG_PlatformPawn here
}
else warn("Wrong target type=" $ target);
If you want to exclude sub classes from execution, use (Target.Class == Class'DummyAnimActor') as condition.
I'll give this a try, but will this still work if I want to use the following to access either actor's array?:

Code: Select all

Target.Sprites[i] = xxxxxx

Re: Grab array in actor, two different actors

Posted: Sat May 27, 2017 3:13 pm
by Barbie
LannFyre wrote:I'll give this a try, but will this still work if I want to use the following to access either actor's array?:

Code: Select all

Target.Sprites[i] = xxxxxx
You have to do a type conversation to access specific class' variables:

Code: Select all

if (DummyAnimActor(Target) != None)
{
   // code for DummyAnimActor here
   DummyAnimActor(Target).DummyAnimActorVariable = Whatever;
}
else if (RPG_PlatformPawn(Target) != None)
{
   // code for RPG_PlatformPawn here
   RPG_PlatformPawn(Target).RPG_PlatformPawnVariable = WhateverElse;
}
else warn("Wrong target type=" $ target);