I want to make a new weapon class that acts like a relic.

  • 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.

Silver_Ibex

Member
Feb 27, 2001
654
0
16
I’m looking for some coding help as what I want to do is a little more advanced then my current skill level.

I need to make a new weapon class that behaves similar to the way relics act, I have already looked at the relic code and don’t know where to start as I want a character having the weapon to also be able to possess/carry a standard relic.

So to sum it up, the idea is something like relics except they are weapons.

Any help would really be appreciated.
 

eXoR

Lead coder
Oct 22, 2001
36
0
0
37
Holland
exorcist.gamepoint.net
So basically you want to give the player that picks up the weapon some special powers, like running faster or whatsoever ?

You could change some of the weapon's owner's (that'll be the player that holds it) properties, like Owner.GroundSpeed or something alike. I guess you should do such a thing in a function that is called as soon as the player picks up the weapon, but you'll have to look for one that's suitable yourself .. if you explain what powers exactly you want to give the player we can give you more info.
 

Silver_Ibex

Member
Feb 27, 2001
654
0
16
The weapon itself is the special power, think of a relic that shoots bullets, and that’s all it does, I don’t need the weapon code, I need to know how to make it teleport randomly about the level like the Relic items already do, thing is that relics are composed of several classes…

Mutator info
Relic
Subclass of relic
Relic inventory

And I’m not sure how much of the code I need to barrow or subclass, I was hoping someone with prior experience modifying the relic code could point out what I need.
 

Papapishu

我是康
Jun 18, 2001
2,043
0
0
42
void
www.vovoid.com
Here's the respawn code from the relic class.
Code:
function PostBeginPlay()
{
	local NavigationPoint NP;

	if (Initialized)
		return;
	Initialized = True;

	// Calculate number of navigation points.
	for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint)
	{
		if (NP.IsA('PathNode'))
			NumPoints++;
	}

	SpawnRelic(0);
	SetTimer(5.0, True);
}

function SpawnRelic(int RecurseCount)
{
	local int PointCount;
	local NavigationPoint NP;
	local RelicInventory Touching;

	NavPoint = Rand(NumPoints);
	for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint)
	{
		if ( NP.IsA('PathNode') )
		{
			if (PointCount == NavPoint)
			{
				// check that there are no other relics here
				if ( RecurseCount < 3 )
					ForEach VisibleCollidingActors(class'RelicInventory', Touching, 40, NP.Location)
					{
						SpawnRelic(RecurseCount + 1);	
						return;
					}

				// Spawn it here.
				SpawnedRelic = Spawn(RelicClass, , , NP.Location);
				SpawnedRelic.MyRelic = Self;
				return;
			}
			PointCount++;
		}
	}
}

function Timer()
{

	if ( (SpawnedRelic != None) && (SpawnedRelic.Owner == None) )
	{
		SpawnedRelic.IdleTime += 5;
		if ( SpawnedRelic.IdleTime >= 30 )
		{
			SpawnedRelic.IdleTime = 0;
			Spawn(class'RelicSpawnEffect', SpawnedRelic,, SpawnedRelic.Location, SpawnedRelic.Rotation);
			SpawnedRelic.Destroy();
		}
	}
}
Hope that helps...
 

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
45
Look outside your window!
Visit site
Yep, you can use the same code, but intead of using RelicInventory object variables, use variables for the weapon you want to use....

I also noticed there's a variable called IdleTime in RelicInventory, which is used to track the time a relic is idle (ie not picked up) so it will desapear and respawn somewhere else, so you should ad a similar variable to your weapon class. The spawning and tracking time of the relics are all handled in the mutator, you don't need to worry about looking elsewhere.
 

Silver_Ibex

Member
Feb 27, 2001
654
0
16
Could you explain in a little more detail what you mean by “use variables for the weapon you want to use....”
 

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
45
Look outside your window!
Visit site
Well, you see, instead of spawning RelicInventory's you would have to make a class variable of the Weapon thingy you want to spawn instead.

So instead of:

SpawnedRelic = Spawn(RelicClass, , , NP.Location);

It should be:

<the weapon thingy> = Spawn(class'<the weapon thingy>,,,NP.Location);