Standard UDamage and Nali Weapons 3

Discussions about Coding and Scripting
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Standard UDamage and Nali Weapons 3

Post by Aldebaran »

Today I have a special problem...
Nali Weapons 3 has its own UDamage class, but there are some reasons why I use the MH2UDamage class (extends Botpack.UDamage) instead because I can integrate it better into the Monster Hunt mod.
With standard weapons I have no graphical issues but with Nali Weapons 3 I have two problems:

1. When activating UDamage ONLY the weapon shows the render effect of UDamage, NOT the hand/fingers of the player. That would not be a problem in general, but it looks not good because the fingers should be placed behind the weapon but they are not. So the complete players hand is shown in front of the red rendered weapon. (see both pictures)
Btw. with standard weapons the hand is red rendered too, so then it works fine...

2. When UDamage ends and the render effect of it is no longer shown in 1st person view, other players still see the weapons red rendered of their teammates. So a player could think the teammates have still UDamage active but not the player himself.

I thought it would be a good idea to integrate the NWCoreVIII class into the Monter Hunt mod so I can better access this Nali Weapons class, but when compiling the source code of it with the GOTY version 4.36 I get this compile error:

Code: Select all

C:\UnrealTournament\NWCoreVIII\Classes\NaliProjectile.uc(341) : Error, Can't assign Const variables
Failed due to errors.  
History: CompileError <- TryCompile <- FScriptCompiler::CompileScript <- (Class NWCoreVIII.NaliProjectile, Pass 1, Line 341) <- CompileScripts <- CompileScripts <- CompileScripts <- CompileScripts <- DoScripts <- UEditorEngine::MakeScripts <- UMakeCommandlet::Main
Exiting due to error
And this is the function of class NWCoreVIII where the error happens:

Code: Select all

simulated function SetWallDecal( vector HitNormal, actor Wall)
{
    local Decal d;
    local bool bFog;
    if ( (ExplosionDecal != None) && (Level.NetMode != NM_DedicatedServer))
    {
        bFog = Region.Zone.bFogZone;
        if (bFog)
//   COMPILE ERROR :
            Region.Zone.bFogZone = False;
		
        d = Spawn(ExplosionDecal,self,,Location, rotator(HitNormal));
	
        if (bDirDecal && DirectionalBlast(d) != None)
            DirectionalBlast(d).DirectionalAttach( initialDir, HitNormal);
		
        if (!bNetTemporary && Level.NetMode != NM_StandAlone)
            ExplosionDecal = None;
		
        Region.Zone.bFogZone = bFog;
    }
}
Perhaps there is a better way to fix the UDamage thing?
Attachments
pic2.jpg
pic1.jpg
Last edited by Aldebaran on Sun Aug 27, 2017 10:20 pm, edited 1 time in total.
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: Standard UDamage and Nali Weapons 3

Post by nogardilaref »

Recompiling a package into the same exact name as the original one is the last thing you should do, since that will create mismatches.
You cannot recompile it either into a new one without recompiling everything else and change every reference from the ini files, which would probably be overkill for what you want to do.

From what I have checked from the source, the main class of these weapons handle the UDamage effect on their own. They detect if there's a UDamage, and if so, they apply the effect you see.
I am unsure why the hands are rendered on top of the weapon though, given that the code only makes the weapon look like that and nothing else (might be a bug in the renderer itself).

Perhaps it would be easier to either disable the hands altogether (they can be disabled iirc), or extend the UDamage version from the mod and add there whichever logic you need from the MH2 version, effectively creating something like a new package to bridge this mod with MH.
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Re: Standard UDamage and Nali Weapons 3

Post by Aldebaran »

nogardilaref wrote:From what I have checked from the source, the main class of these weapons handle the UDamage effect on their own. They detect if there's a UDamage, and if so, they apply the effect you see.
Thank you for the investigation. So it makes no sense to go further at this point (usage of Botpack.UDamage with the non-fixable NW3 weaponhands).
nogardilaref wrote:Recompiling a package into the same exact name as the original one is the last thing you should do, since that will create mismatches.
I know, but I don't want to produce a new NW3 package, I want to compile it with my Monster Hunt mod, so I can perhaps access the NW3 weapon class directly from the Monster Hunt mod and spawn/set some udamage/variables.
In such a case I don't need the Botpack.UDamage anymore and I could use the NW3 UDamage instead.
The Monster Hunt mod will detect if NW3 are loaded or not, so it will decide how UDamage will be handled.

I would like to have these 3 options in UDamage that aren't doable with NW3 UDamage at this time:
- I want increase ActiveTime (standard 30 is too low for me), I can configure that in the NW3 config file but it seems not to work
- I want UDamage randomly be spawned via my Monster Hunt mod, not via RandomRewards of NW3
- I want to embed the actual charge of the UDamage into the Monster Hunt HUD

So to change this I have to know why I can't compile the NWCoreVIII...
I think I got it from here:
http://www.moddb.com/mods/nali-weapons- ... opers-only
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: Standard UDamage and Nali Weapons 3

Post by nogardilaref »

Aldebaran wrote: - I want increase ActiveTime (standard 30 is too low for me), I can configure that in the NW3 config file but it seems not to work
I just edited this section from NWExtrasCfg.ini:

Code: Select all

[NWExtrasVIII.NWUDamage]
ActiveTime=30
MaxActiveTime=90
DamageMultiplier=3.000000
and I set the ActiveTime to 90 and it worked.
As you can see, there's also a MaxActiveTime, so if you want to increase, let's say, to 120, probably you have to increase this one as well, or the value will get truncated.
Aldebaran wrote: - I want UDamage randomly be spawned via my Monster Hunt mod, not via RandomRewards of NW3
And why do you think cannot you do so?
It doesn't really matter the mod you use, if the class is there, you can spawn it and do whatever you want with it. Is there any specific difficulty you're having with NW3 UDamage itself that you don't with your own UDamage?
Aldebaran wrote: - I want to embed the actual charge of the UDamage into the Monster Hunt HUD
Which you can also do so. I don't know how you're going about this, if this is an already existing HUD or if you're referring to your own, but in either case, if it's an already existing one, you can extend it and switch the MH one by your own, and in there you can override the function responsible to show the UDamage charge.

Of course, depending on how you do this, this might mean that your package must use the NW3 mod as a dependency (depending on whether or not you use dynamic calls or direct ones).
Aldebaran wrote: So to change this I have to know why I can't compile the NWCoreVIII...
Again, if you compile it directly, you're going to break NW3 for everyone who actually have the mod installed, by creating a mismatching file, it will only hurt you and others if you do it that way.
If you wish to compile it anyway, at least change the package name to avoid these mismatches, although this means recompiling all the other packages as well, under new names, and changing every reference towards the old packages in the .ini, .int and even potentially in some .uc files, hence why I think it's overkill since all you want to fix is the UDamage behavior.

You can generally have a good deal of control over any actor, without having to recompile it or create a dependency for it, and you can dynamically load them through their name alone, as well as checking the class without actually "knowing" it, and even change its properties through "SetPropertyText" rather than directly.

As for why it doesn't compile, it's because it's trying to change a value which is actually constant.
It does seem to be done on purpose however, as I have seen something similar in ONP, which was meant to fix decals in fog zones, which consisted in setting the zone as a non-fog zone, create the decal and then revert the change, but the property is constant.

A curious fact about the engine however, is that no constant property is actually "constant", the modifier should be called "readonly" instead, and it's only evaluated at compile-time and not at run-time.
Therefore, if you remove the constant modifier from any property from any package, recompile it, and then compile your own package where you change such a property, it will compile without issues and you will be able to change the property, even after you revert the other package to its original one.
That's what probably was done here, so it will only compile with a game package version which doesn't have this property set as constant.

This hack is not advised to do unless you know the full repercussions of what you're changing, since generally these properties are constant since they should not really be changed directly, but through a function call instead (like SetLocation for Location). In the case of the fog property, there's no such function, so there's no alternative.


If you wish, post here the source or some code, and I can try to help you with what you want to do.
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Re: Standard UDamage and Nali Weapons 3

Post by Aldebaran »

nogardilaref wrote:I just edited this section from NWExtrasCfg.ini and I set the ActiveTime to 90 and it worked.
I tried it today again and you are right, now it works :shock: I don't know what I did wrong...
nogardilaref wrote:if you remove the constant modifier from any property from any package
Thanx! I will try this some time later. It would be good to know if this solves the compiling problem.
nogardilaref wrote:You can generally have a good deal of control over any actor, without having to recompile it or create a dependency for it, and you can dynamically load them through their name alone, as well as checking the class without actually "knowing" it, and even change its properties through "SetPropertyText" rather than directly.
I did not knew this, sorry. Is it possible to give me an example how I read a variable of an NWExtrasVIII.NWUDamage instance or how I set another activation sound for the NWExtrasVIII.NWUDamage class without creating a dependency?
And how can I spawn a class that is not known by the compiler?
I would be very grateful for that.
Or exist a sample already in this forum?

Btw I think I know now why some ingame messages appears twice, we have discussed this here viewtopic.php?f=7&t=11474. Because perhaps Nali Weapons 3 calls some pickup functions twice, one time for it's own and one time for the Botpack version...
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Standard UDamage and Nali Weapons 3

Post by Barbie »

Aldebaran wrote:- I want to embed the actual charge of the UDamage into the Monster Hunt HUD
I have already done this, but I had to recode BotPack.UDamage, because its Charge does not change actually. Instead a timer to the end of lifespan is set when it is picked up.
My version of UDamage

Code: Select all

class UDamageSB extends UDamage;

state Activated {

	function Timer()
	{
		Charge -= 10;
		if (Charge <= 0) 
		{
			Pawn(Owner).ClientMessage(ExpireMessage);
			UsedUp();
			return;	
		}

		if (Charge < FinalCount)
			Owner.PlaySound(DeActivateSound,, 8);
	}


	function BeginState()
	{
		Super.BeginState();
		// original FinalCount is in seconds; change to 1/10 seconds
		FinalCount *= 10;
		SetTimer(1, true);
	}
}
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Re: Standard UDamage and Nali Weapons 3

Post by Aldebaran »

Thanx, Barbie. In my actual Monster Hunt mod I have done a working HUD already, I adapted the MH2UDamage class for this.
Now it's time to get the NWExtrasVIII.NWUDamage working instead...
If it is really possible what nogardilaref said, there would be more possibilites for other things too in combination with the Nali Weapons 3 mod and a custom Monster Hunt mod (for example change the weapon strength and so on)?
Last edited by Aldebaran on Mon Aug 28, 2017 2:27 am, edited 1 time in total.
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: Standard UDamage and Nali Weapons 3

Post by nogardilaref »

Aldebaran wrote: I did not knew this, sorry. Is it possible to give me an example how I read a variable of an NWExtrasVIII.NWUDamage instance or how I set another activation sound for the NWExtrasVIII.NWUDamage class without creating a dependency?
I would be very grateful for that.
Or exist a sample already in this forum?
First, you must just get a reference to the NWUDamage actor itself. Notice that you will not be seeing it as actually a "NWUDamage", you're going to see it as simply "Inventory".
To "detect" a NWUDamage without actually depend on it, you use "IsA":

Code: Select all

local Inventory Inv;
...
if (Inv.IsA('NWUDamage')) {
     //it's a NWUDamage, do stuff with it
}
If you want to be more specific and detect the package as well, you just have to check its class typecasted to a string, which should include the package name.

From here, NWUDamage happens to use the same Charge and PickupSound properties already declared in the Inventory class, so you do not actually need to reference them dynamically, thus you can simply:

Code: Select all

Inv.Charge = 1000; //some value here
Inv.PickupSound = Sound'SomeSound'; //some sound here
However, other things that it uses are either declared in NWUDamage or NaliPickups which it extends, so those you need to do this:

Code: Select all

Inv.SetPropertyText("MaxCharge", Charge); //Set MaxCharge to the same as Charge
You will notice that it sets up some default properties, but they don't seem to be used anywhere for the UDamage.
SetPropertyText and GetPropertyText have some limitations however: they cannot deal with default values, nor composite types of any kind (structs and arrays), if I am not mistaken.
Aldebaran wrote: Btw I think I know now why some ingame messages appears twice, we have discussed this here viewtopic.php?f=7&t=11474. Because perhaps Nali Weapons 3 calls some pickup functions twice, one time for it's own and one time for the Botpack version...
Just checked, it does get called twice when it expires, but not for that reason.
PickupExpired is called in 2 places: in Timer and Destroyed, but Timer also calls Destroy which fires the Destroyed event, so it's called twice.
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Re: Standard UDamage and Nali Weapons 3

Post by Aldebaran »

This is my function to give UDamage randomly to players (or increase time to max).
How should I rewrite the MH2UDamage part, that instead a NWExtrasVIII.NWUDamage will be given?

Code: Select all

function GiveAmp(Pawn PlayerPawn)
{
   local MH2UDamage damage; 
   local Inventory Inv;

   if (PlayerPawn.Health <= 0) 
      return;

   Inv = PlayerPawn.FindInventoryType(class'MH2UDamage');
   if (Inv != None)  
   {
	  MH2UDamage(Inv).FinalCount = MH2UDamage(Inv).Default.FinalCount;
	  MH2UDamage(Inv).Charge = MH2UDamage(Inv).Default.Charge;
      return;
   }

   damage = spawn(class'MH2UDamage',PlayerPawn,,PlayerPawn.Location);
   if( damage != None )
   {
      damage.RespawnTime = 0.0;
      damage.GiveTo(PlayerPawn);
      damage.Activate();
   }
}
Last edited by Aldebaran on Sun Aug 27, 2017 10:19 pm, edited 1 time in total.
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: Standard UDamage and Nali Weapons 3

Post by nogardilaref »

As you can see, FindInventoryType requires an actual class reference to be given, which forces you to build a dependency, so that's not what you want to use.

Instead, you have you create your own FindInventory function:

Code: Select all

function Inventory FindInventory(Pawn P, name ClassName)
{
	local Inventory Inv;

	for (Inv = P.Inventory; Inv != None; Inv = Inv.Inventory) {   
		if (Inv.IsA(ClassName)) {
			return Inv;
		}
	}
	return None;
}
You could have the function receive the full class string instead and check the classes typecasted to strings, but I will leave such implementation details up to you.

And then:

Code: Select all

function GiveAmp(Pawn PlayerPawn)
{
	local Inventory Inv;
	local class<Inventory> InvClass;

	Inv = FindInventory(PlayerPawn, 'NWUDamage');
	if (Inv != None) {
		Inv.Charge = Inv.Default.Charge;
		return;
	}
	
	InvClass = class<Inventory>(DynamicLoadObject("NWExtrasVIII.NWUDamage", class'Class'));
	if (InvClass != None ) {
		Inv = Spawn(InvClass, PlayerPawn,, PlayerPawn.Location);
		if (Inv != None) {
			Inv.Touch(PlayerPawn);
			if (!Inv.bDeleteMe && Inv.Owner != PlayerPawn) {
				Inv.Destroy();
			}
		}
	}
}
You will notice that I didn't set FinalCount, because it isn't really needed (it's a value that is read-only, not written to), and I used another way of activating the pickup (it's best to just trigger what would happen normally when a player touched the pickup, than to replicate every line of code of what it does, abstracting you from any implementation details on what it "means" to activate the pickup).


However, since NWUDamage is able to recharge on its own already, you can actually just have this:

Code: Select all

function GiveAmp(Pawn PlayerPawn)
{
	local Inventory Inv;
	local class<Inventory> InvClass;

	InvClass = class<Inventory>(DynamicLoadObject("NWExtrasVIII.NWUDamage", class'Class'));
	if (InvClass != None ) {
		Inv = Spawn(InvClass, PlayerPawn,, PlayerPawn.Location);
		if (Inv != None) {
			Inv.Touch(PlayerPawn);
			if (!Inv.bDeleteMe && Inv.Owner != PlayerPawn) {
				Inv.Destroy();
			}
		}
	}
}
Not as efficient but, in programming, abstraction is generally preferred to performance, specially when the performance gain isn't meaningful.
But the FindInventory function will still come in handy for the HUD.
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Standard UDamage and Nali Weapons 3

Post by Barbie »

nogardilaref wrote:

Code: Select all

Inv.PickupSound = Sound'SomeSound'; //some sound here
This only works on client if client has already loaded that sound - this is true for sounds used in the map and (AFAIR) as well as for UnrealShare sounds.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Re: Standard UDamage and Nali Weapons 3

Post by Aldebaran »

Thank you nogardilaref, you helped me alot.
With Nali Weapons 3 in the GivenAmp function I have now the problem that often the Amp item is spawned where a player stood but it was not taken by him. I have had not that problem with Botpack.UDamage. I deleted the Inv.Touch function for testing but it did not help. Perhaps it needs too much time for spawning the Amp and the player is going elsewhere in that time.

EDIT: Oooops, I forgot to set value of RespawnTime to 0.0... perhaps that was the reason, I have to test this.

Another question:
Can I set the PickupSound=Sound'Botpack.Pickups.AmpPickup' AFTER finding the InvClass but BEFORE it is spawned? I mean how can I change a class value before it is spawned?
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: Standard UDamage and Nali Weapons 3

Post by nogardilaref »

Sorry, my mistake:

Code: Select all

Inv = Spawn(InvClass, PlayerPawn,, PlayerPawn.Location);
should actually be:

Code: Select all

Inv = Spawn(InvClass,,, PlayerPawn.Location);
without the PlayerPawn as a Owner, otherwise the "Inv.Owner != PlayerPawn" condition will always fail, hence it staying where it was spawned.

Also, it doesn't matter how far away the spawned inventory is from the player, by calling the Touch event directly, it's as if the player really touched it.
The only reason why it's spawned at the PlayerPawn.Location is simply to try to guarantee that it always spawns at a valid location, and is the simplest way of doing it.
Aldebaran wrote: Can I set the PickupSound=Sound'Botpack.Pickups.AmpPickup' AFTER finding the InvClass but BEFORE it is spawned? I mean how can I change a class value before it is spawned?
Yes:

Code: Select all

InvClass.default.PickupSound = Sound'Botpack.Pickups.AmpPickup';
Although it's generally not advised to do so, for a few reasons. Why do you want to do it?
Barbie wrote:
nogardilaref wrote:

Code: Select all

Inv.PickupSound = Sound'SomeSound'; //some sound here
This only works on client if client has already loaded that sound - this is true for sounds used in the map and (AFAIR) as well as for UnrealShare sounds.
Could you elaborate a bit?
I am not sure if I understood you correctly, but, as far as I know, whenever you reference a resource directly, there isn't really any margin for the load to fail without crashing completely.
If you mean when you dynamically load sounds or other resources (DynamicLoadObject), if they aren't sent through ServerPackages, then yeah, they will fail.
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Re: Standard UDamage and Nali Weapons 3

Post by Aldebaran »

nogardilaref wrote:Although it's generally not advised to do so, for a few reasons. Why do you want to do it?
Only for some optical reasons. The NWUDamage class has Charge=30 as default, but I use a higher value. Now if using the GiveAmp function in the first 1-2 seconds I see in my HUD the value of 30 instead of my max value. I want to see my value right from start so I will try to change the Charge default value before the UDamage is spawned.

There is only one thing left, but it has not to do with UDamage directly.
I have made a class Invulnerable based on Barbies Pickup. The problem is that all standard weapons and most other weapons changes their surface while it is active, so players perceive it better.
But Nali Weapons 3 don't change it.
Now I am on it to adapt the Invulnerable function, perhaps a translucent style would be nice.

This is the main function for it:

Code: Select all

function SetWeaponEffect()
{
	if ( ! bProtectionActive)
		return;

	// Make old weapon normal again.
	if (CurrentWeapon != None)
		CurrentWeapon.SetDefaultDisplayProperties();

	CurrentWeapon = Pawn(Owner).Weapon;
	// Make new weapon cool.
	if (CurrentWeapon != None)
		if (Level.bHighDetailMode)
			CurrentWeapon.SetDisplayProperties(ERenderStyle.STY_Translucent, EffectTexture, true, true);
		else
			CurrentWeapon.SetDisplayProperties(ERenderStyle.STY_Normal, EffectTexture, true, true);
}
Also it can be that Invulnerable and UDamage overlap, so I am looking for that solution too. But first it is important that the Nali Weapons become translucent (or another style to not mixed up with Invisibility) while Invulnerable is activ.
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: Standard UDamage and Nali Weapons 3

Post by nogardilaref »

Well, that's not going to work very well.
One of the many problems with modifying default values is that they will cause your custom charge value to not get replicated to the client at all.
Why? Because one of the bases of replication is only to replicate data which was changed, and after a spawn, a value is only considered to have been changed if it differs from its default.

Thus if you make a default value equal to the custom value you want to set, you won't ever see that on your HUD in an online game.

Actually, this is the very problem that I see in NWUDamage: in PreBeginPlay it's setting up defaults as well, but it shouldn't, so the Charge value won't get replicated until a moment later when it's decreased in the NaliPickups code.
What you can do, right after the Touch being called, which might just work, is:

Code: Select all

Inv = FindInventory(PlayerPawn, 'NWUDamage');
if (Inv != None) {
    Inv.default.Charge = Inv.Charge + 1;
}
It's a bit of a hack, but it might just work.


As for the Invulnerable pickup, like I noted previously, this mod does its own thing concerning the visuals of the weapons themselves.
Thus your only hope in that case is to create an Invulnerable pickup by extending NaliPickups itself, since you would have to set up these default values (taken from NWUDamage as an example):

Code: Select all

bOverlayWeaponFX=True
bThirdPersonWeaponFX=True
bWeaponAffector=True
WeaponFXOverlayStyle=STY_Translucent
WeaponFXThirdPersonStyle=STY_Translucent
bTeamBasedWeaponFX=False
WeaponFXOverlayTex(0)=Texture'NeoXUDamFluid'
WeaponFXThirdPersonTex(0)=Texture'NeoXUDamFluid'
bWeaponFXOverlayEnviroMap=True
bWeaponFXThirdPersonEnviroMap=True
WeaponFXOverlayExtraFatness=0
bWeaponFXOverlayUnlit=True
bWeaponFXThirdPersonUnlit=True
WeaponFXOverlayGlow=1.500000
WeaponFXThirdPersonGlow=1.000000
This creates a dependency towards the NW3 core package however of course, but there's really no way around that.
If you do this, you might as well extend the NWUDamage and fix its problems too.
Post Reply