Page 2 of 2

Re: How to transfer damage taken from a class to another?

Posted: Wed 05 Oct , 2011 12:35 am
by Azarael
Typecast M to DreamsCombineBackup1A using the following code:

DreamsCombineBackup1A(M).FirstMonster = self;

Typecasting tells the compiler to treat a variable which contains a class as if it contained a variable of one of its subclasses. If it's not done, you can only access properties which exist in the class you originally defined the variable as containing. It's up to you to make sure that the variable actually contains a reference to an instance of that class, otherwise you'll get an Accessed None, but it won't be a problem here.

For example:

var Actor A;

I then assign a Pawn to A and try to access the GroundSpeed property, but cannot because the variable A was declared as holding was an Actor. Therefore I must use Pawn(A).GroundSpeed when trying to access a Pawn-specific property.

Re: How to transfer damage taken from a class to another?

Posted: Wed 05 Oct , 2011 3:51 am
by LegendaryAgent
Azarael wrote:Typecast M to DreamsCombineBackup1A using the following code:

DreamsCombineBackup1A(M).FirstMonster = self;

Typecasting tells the compiler to treat a variable which contains a class as if it contained a variable of one of its subclasses. If it's not done, you can only access properties which exist in the class you originally defined the variable as containing. It's up to you to make sure that the variable actually contains a reference to an instance of that class, otherwise you'll get an Accessed None, but it won't be a problem here.

For example:

var Actor A;

I then assign a Pawn to A and try to access the GroundSpeed property, but cannot because the variable A was declared as holding was an Actor. Therefore I must use Pawn(A).GroundSpeed when trying to access a Pawn-specific property.

:O this is brilliant, this is is basically getting the id of the specific object dreamscombinebackup1a and save it to (M) variable? this is awsome and gives me many possibilities :D
I will soon post a reply, if not today it means im in bed and will do in a few hours later.
Thanks as usual for the awsome explanation aza

Re: How to transfer damage taken from a class to another?

Posted: Wed 05 Oct , 2011 1:06 pm
by Azarael
No problem.

That's not exactly how typecasting works. When you do Class(Variable) you're just telling the compiler to treat Variable as if it were subclass Class for the duration of that statement. You don't actually modify the variable you typecast. For example:



function AssignSomething(Pawn Other)
{

local Actor A;

A = Other; //assign Pawn Other to variable A which is declared as holding an Actor
A.GroundSpeed = 500; //fails, A is currently being treated as an Actor
Pawn(A).GroundSpeed = 500; //success, A is being treated in this statement as a Pawn
A.AirSpeed = 500; //fails, A isn't changed in any way by the above typecasting, it still holds an Actor
Pawn(A).AirSpeed = 500; //success, A is being treated once again as a Pawn

}

Re: How to transfer damage taken from a class to another?

Posted: Wed 05 Oct , 2011 6:17 pm
by LegendaryAgent
Hey, back again, thx for ur help izumo once more, this is what i have coded, i have tried my best that in all cases if one of them "dies" so will the other in every single possible case including telefrags:

DreamsBossHunter1A

Code: Select all

simulated function Destroyed()
{
    if(DreamsCombineBackup1A(M) != none && DreamsCombineBackup1A(M).PawnHealth>0)
    {
    DreamsCombineBackup1A(M).FirstMonster = None;
    DreamsCombineBackup1A(M).Destroy();
    M = none;
    }
    Super.Destroyed();
}

function TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType)
{
 Super.TakeDamage(Damage,instigatedBy,hitlocation,momentum,damageType);
 if(M != none && Health < 1)
 {
 DreamsCombineBackup1A(M).FirstMonster = None;
 DreamsCombineBackup1A(M).TakeDamage(Damage,instigatedBy,hitlocation,momentum,damageType);
 M = none;
 }
}
DreamsCombineBackup1A

Code: Select all

simulated function Destroyed()
{
    if (DreamsBossHunter1A(FirstMonster) != none && DreamsBossHunter1A(FirstMonster).PawnHealth > 0)
    {
    DreamsBossHunter1A(FirstMonster).M = none;
    DreamsBossHunter1A(FirstMonster).Destroy();
    FirstMonster = none;
    }
    Super.Destroyed();
}

function TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType)
{
 if (DreamsBossHunter1A(FirstMonster) != none && DreamsBossHunter1A(FirstMonster).PawnHealth > 0)
 DreamsBossHunter1A(FirstMonster).TakeDamage(Damage,instigatedBy,hitlocation,momentum,damageType);
 else
 {
 DreamsBossHunter1A(FirstMonster).M = none;
 FirstMonster = none;
 Super.TakeDamage(Health,instigatedBy,hitlocation,momentum,damageType);

 }
}

What do u think? is it good enough?
Oh theres a problem, how can i give damage to the boss when its minion gets destroyed? i need to kill it through damage because some funky things happen in invasion wave end if i simply destroy the boss.

if i type
DreamsBossHunter1A(FirstMonster).TakeDamage(DreamsBossHunter1A(FirstMonster).PawnHealth,instigatedBy,hitlocation,momentum,damageType);
in the minion destroy event i get this error:
C:\UT2004\HL2ML31A\Classes\DreamsCombineBackup1A.uc(22) : Error, Call to 'TakeDamage': bad or missing parameter 2

Re: How to transfer damage taken from a class to another?

Posted: Wed 05 Oct , 2011 7:22 pm
by Azarael
Set the second parameter to be the boss. Remember you're calling this function alone, and not as a superclass function within itself. You'll need to add values instead of using hitlocation, instigatedby, etc. Make some up.

Re: How to transfer damage taken from a class to another?

Posted: Wed 05 Oct , 2011 8:03 pm
by LegendaryAgent
Azarael wrote:Set the second parameter to be the boss. Remember you're calling this function alone, and not as a superclass function within itself. You'll need to add values instead of using hitlocation, instigatedby, etc. Make some up.
ah ic, well i dont know what to type in momentum, if i type a number it says missmatch :S
this is what i have so far:

DreamsBossHunter1A(FirstMonster).TakeDamage(DreamsBossHunter1A(FirstMonster).PawnHealth,self,DreamsBossHunter1A(FirstMonster).Location,momentum,XWeapons.DamTypeLinkPlasma);

isnt momentum the value that knocks enemies off? like shock balls knocking off a hellbender for example?

Re: How to transfer damage taken from a class to another?

Posted: Wed 05 Oct , 2011 9:22 pm
by Azarael
Momentum takes a vector, because it's directional. Use vect(0,0,0) if you want no momentum to be applied.

class'DamTypeLinkPlasma' is the required entry for the damagetype.

Re: How to transfer damage taken from a class to another?

Posted: Thu 06 Oct , 2011 3:49 am
by LegendaryAgent
Azarael wrote:Momentum takes a vector, because it's directional. Use vect(0,0,0) if you want no momentum to be applied.

class'DamTypeLinkPlasma' is the required entry for the damagetype.

Thank you very much aza, its working like a charm both offline and online!

Again thanks alot for your help on this matter and for the explanations :D

Re: How to transfer damage taken from a class to another?

Posted: Thu 06 Oct , 2011 12:28 pm
by Azarael
Any time. Holla back if you need any more help.