UE3 - UT3 Function GiveTo in UE3, how is the procedure?

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

ShadowsWar

New Member
Nov 30, 2008
76
0
0
Hi, again XD, I was trying to add a inventory to a player, but I'm heaving some troubles switching from ut2k4 to ue3 =/

Here is the inventory code:
Code:
class DelayedDmgInv extends Inventory;

var Controller InstigatorController;
var Pawn PawnOwner;
var int Modifier;

replication
{
	reliable if (bNetInitial && Role == ROLE_Authority)
		PawnOwner;
}

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();

	if (Instigator != None)
		InstigatorController = Instigator.Controller;

	SetTimer(1, true);
}

function GiveTo(Pawn Other, optional Pickup Pickup)
{
	local Pawn OldInstigator;

	if (InstigatorController == None)
		InstigatorController = Other.DelayedDamageInstigatorController;

	OldInstigator = Instigator;
	Super.GiveTo(Other);
	PawnOwner = Other;
	Instigator = OldInstigator;
}

simulated function Timer()
{
	if (Role == ROLE_Authority)
	{
		if (Owner == None)
		{
			Destroy();
			return;
		}

		if (Instigator == None && InstigatorController != None)
			Instigator = InstigatorController.Pawn;

		PawnOwner.DelayedDamageInstigatorController = InstigatorController;
		PawnOwner.TakeDamage(Modifier * 2, Instigator, PawnOwner.Location, vect(0,0,0), class'DamTypeXGun');
	}

}

defaultproperties
{
	bOnlyRelevantToOwner=false
}
And I'm getting a error saying that there is no Pickup class...so I was wandering what is the actual header of the GiveTo function of a inventory.
I tried to search in Unreal Wiki, but could only find the ones from ut,ut2kx
 

ShadowsWar

New Member
Nov 30, 2008
76
0
0
ok, so I found out that the giveto only uses the pawn, but it says now that it can't override a final function =X
What should I do then? Is there a alternative way of doing this?
 

Sir_Brizz

Administrator
Staff member
Feb 3, 2000
26,020
83
48
When do you want the weapons to be given? If it's at match start, you can modify the default inventory in the game like so:
Code:
function InitMutator(string Options, out string ErrorMessage)
{
     local UTGame Game;

    Game = UTGame(WorldInfo.Game);
    Game.DefaultInventory.AddItem([[some weapon pickup class name]]);
}
On a side note, Pawn.GiveTo is a function available to any Pawn, even if you make a new one that extends from Pawn... so you shouldn't have to re-implement its functionality.
 

ShadowsWar

New Member
Nov 30, 2008
76
0
0
er.. no, it's not a weapon I want to be given, I wanted to add a delayed damage, you know, a gun that you shoot and instead of damaging the target it would do a delayed damage.
So I thought that it is done by giving a inventory for the targeted player with the shoot info(and in the inventory a timer, so that after the timer is done, the player takes the damage and destroys the inventary)
 

Sir_Brizz

Administrator
Staff member
Feb 3, 2000
26,020
83
48
Ah...

You could do it that way, however you'd need to create a new inventory item (probably a UTWeapon subclass) that has that functionality in it.
 

ShadowsWar

New Member
Nov 30, 2008
76
0
0
Humm.... Don't know if I understand the hole deal, but anyway, what could be another way of doing that?
 

Sir_Brizz

Administrator
Staff member
Feb 3, 2000
26,020
83
48
I'd just make a custom pawn like you have and add an attribute that tells if the person has whatever effect you want to be added. Then in the tick function of your mod, just go through all the pawns in the level and see if they have had that attribute set. Keep a running total of the time they've had it set and run a function on your Pawn class when the time runs out.

There are other ways you could do it. There may be timer/tick functions on other classes that you can use, I'm not sure (haven't messed with it in a while). No guarantee that this is the best way to do it :)
 

ShadowsWar

New Member
Nov 30, 2008
76
0
0
Humm.... anyway thanks for the help, I'll do some test, and then if I found a better way I post it here.
 

ShadowsWar

New Member
Nov 30, 2008
76
0
0
Ok, here's what I've done:
Replaced the weapons by my one new weapon that has a delayed shoot;
Created a new inventory named MyDelayedDamege
And a new DamageType too.
Then replaced ProcessInstantHit in the weapon, so that when the player shoot a valid target it will check to see if is a pawn and then give the MyDelayedDamage to this targed, then set the inventory's variables(such as timer,lifespan, and controller)...
then is just shoot, wait and see ^^
I'm just with a problem...
Do you know how I make a damage explode the target body when it dies?