UE1 - UT Scriptedpawn - Instant location change

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Neo_b

New Member
Jul 2, 2008
72
0
0
Hello, I have a problem with my portals again. I have fixed the problems before, but now when a scriptedpawn teleports with it while it attacks the player (simple SetLocation function), it walks just straight and doesnt react to anything the player does except touching him so it starts fighting him (some fighting technique switch function I think). Is there any way to fix it? What is its reason? I'm not good at Scriptedpawn AI. Thanks in advance.

Edit: I would also ask how to make 2 scriptedpawns not attacking themselves.
 
Last edited:

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
It's been a while since I had a look at scripted pawns. Somewhere in there you'll find some code that handles "attitude" as multiple states of a class. The state where a creature doesn't attack another is friendly (see how Nalis and nali cows work).

As for what happens after teleportation it's similar to what you'd get if a playerpawn has bInvisible set to true. A hostile creature will only start attacking when you touch it (this is handled explicitely). I'd have a look at how a playerpawn is detected when no touchign is taking place.
 

Neo_b

New Member
Jul 2, 2008
72
0
0
Thanks for info. ;) I made a terrible mistake in changing a scriptedpawn's state to non-existent one (by mistake). I thought about player when I wrote that code. I already checked the scriptedpawn code for finding team, but strangely in my NPortalSpawn class neither the SetPropertyText nor GetPropertyText works...

Here's the code:

Code:
//=============================================================================
// NPortalSpawn.
//=============================================================================
class NPortalSpawn expands NActors;

var() class<actor> SpawnClass;
var() EPhysics SpawnPhysics;
var() rotator SpawnRotation, SpawnDir;
var() vector SpawnVelocity;
var() name SpawnTag, PortalTag, SpawnEvent;
var() bool bSetPhysics, bSetVelocity, bSetVariables, bMultiplePortals;
var() string Variables[16], Values[16];

function Trigger(actor Other, pawn EventInstigator)
{
local NPortal NP;
local actor A;
local float Value;

    foreach AllActors(class'NPortal', NP)
    {
        if(NP!=None && NP.bEnabled && NP.ThisPortalTag==PortalTag)
        {
            NP.Disable('Touch');
            
            Value=abs(SpawnDir.Pitch/16384);
    
            Value=Value*(NP.CollisionHeight+SpawnClass.Default.CollisionHeight)+(1-Value)*(NP.CollisionRadius+SpawnClass.Default.CollisionRadius);
    
            A=Spawn(SpawnClass,,, NP.Location+vector(SpawnDir)*Value, SpawnRotation);
            
            if(A!=None)
            {
                A.Tag=SpawnTag;
                A.Event=SpawnEvent;
            
                if(bSetVariables)
                {
                    SetVariables(A);
                }
            
                NP.SetTimer(0.02, True);
                
                if(bSetPhysics)
                {
                    a.SetPhysics(SpawnPhysics);
                }
                
                if(bSetVelocity)
                {
                    a.Velocity=SpawnVelocity;
                }
            }
        
            NP.Enable('Touch');
            
            if(!bMultiplePortals)
            {
                return;
            }
        }
    }
}

function SetVariables(actor A)
{
local int i;
    for(i=0; i<16; i++)
    {
          if(Variables[i]!="")
          {
                A.SetPropertyText(Variables[i], Values[i]);
          }
    }
}

NPortal is my teleporter class. It doesn't set the variables... I checked it without any config, simply A.SetPropertyText("Health", "30") and it didn't work... Thanks in advance.
 

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
I have little experience with SetPropertyText. However I do remember that setting names can be a pain (I'm willing to bet that an array expression won't work). Try the workaround on this page: http://wiki.beyondunreal.com/Legacy:Typecasting

It's also a good idea to make your class so that all methods it contains modify the state of the object, or modify the state of others.
 
Last edited:

Neo_b

New Member
Jul 2, 2008
72
0
0
Thanks, but I also tried it without arrays. And it's my class. :p And I'd like it to be universal, so I don't have to modify it every time I want it to set a new variable. I have another class, which just sets variables from an array:

Code:
//=============================================================================
// NVariableSet.
//=============================================================================
class NVariableSet expands NActors;

var() string Variable, Value, SecondValue;
var() bool bUseSecondValue;
var bool bSecond;

function Trigger(actor Other, pawn EventInstigator)
{
local actor A;
local string RealValue;

	if(Variable=="")
	{
		return;
	}

	if(bSecond && bUseSecondValue)
	{
		RealValue=SecondValue;
	}else{
		RealValue=Value;
	}

	foreach AllActors(class'Actor', A, Event)
	{
		A.SetPropertyText(Variable, RealValue);
	}
	
	bSecond=!bSecond;
}

Works fine. Wondering why...
 

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
What exactly are you trying to achieve ?
 

Neo_b

New Member
Jul 2, 2008
72
0
0
There's a NPortal class -> simply a teleporter with a sprite set and which is able to disappear / appear by being triggered. I can use my NPortalSpawn to spawn an actor at the NPortal (as if it was teleported from some other portal), but I would like to give this spawned actor some features (for example set its Health or TeamTag).
 

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
Hmm, imo SetPropertyText will only change the default values. This might end up having no effect as I think the default values are only taken into account when an object is created.

What you'd need to do is create/instantiate an object and then set it's values directly. For example, SomeObject.Health = value or, if the attribute is private, use a setter method that does it indirectly like SomeObject.SetHealth(value).

You can access an object once it's instantiated using it's reference (a value that allows uscript to find the object in memory). This is done either explicitely - ClassName aClassName = New ClassName() - or by passing on the value of a parameter sent to a method in the class your working on.
 
Last edited:

Neo_b

New Member
Jul 2, 2008
72
0
0
1. SetPropertyText sets the value properly in the other class (non-default one).
2. You didn't understand what I need to do. My goal is to make the actor customizable in UnrealED. What I mean is that I would like to be able to set the values I wanna set to which variables in the actor properties window (I don't want to add variables: SetPawnHealth, SetWeaponAmmo, SetActorMesh, SetActorTexture, SetPawnSkill... etc, because it's pointless, instead I'd like to choose variables and values). :)

Edit: By the way, is there any way to import a mesh from UnrealEditor? (without using UCC) Or if there's no such way, can I import meshes to existing package without creating a new one?
 
Last edited:

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
1. If you're sure of this then ok.
2. Of course I don't understand. It took four replies to get to the point where you say this is to add something to UnrealEd. If I'd have known the answer would be, I don't know. Same goes for the mesh.

3. Leave the topic as it is and see how many people reply. Then ask yourself, wouldn't it be more productive to go straight to the point :p ?
 

Neo_b

New Member
Jul 2, 2008
72
0
0
Oh, I'm sorry, I thought I went straight to the point in the beginning. Thanks for your effort. ;)
 

Neo_b

New Member
Jul 2, 2008
72
0
0
Sorry for double-post, I'd just like everyone to know that there's a new post here. Tell me if it's wrong here. ;p I just wanted to add some information to my problem. I can't use SetPropertyText on a just-spawned actor. I also can't use it on it when I use Timer or Tick so it sets the variables like 1 sec or more after spawning. But the same class can set variables of levelinfo just fine. And I made logging in some places, I found out that the execution reaches the SetPropertyText fine, that the parameters are also fine. I even made local string variables to give them values of the array member I wanted to use, but it also didn't help. You know, now I think it's some kind of dark magic now, I mean it's impossible! And the class I wish to spawn is SkaarjWarrior, it's a normal class, so I wonder where the problem could be? Anybody has any ideas? Thanks in advance... It's really very weird.