PDA

View Full Version : Damage Pickup based on UDamage [Please help a newbie :)]



legacy-KillBait!
05-22-2003, 02:05 PM
Im a newbie to UScript so be gentle :)

I'm making a damage pickup diffeent to the UDamge, but i have run into a bit of a problem which i hope somebody
can help me with.

It is based on the UDamage code and i already have the pickup working ingame using wilcard/xpickupbase and
the actor itself and a mutator to replace the double damage with it, but at the moment it still reduces the player health by the same amount of the udamage.

I can't seem to figure out a way of changing the amount of damage done to a player when using the new pickup. I found the code which does the double damage in the engine.pawn class TakeDamage() but as changing that code is a no go, i don't know how to link my changed damage code to the pickup.

Can anybody give me a hint as how to do this.?

This is the first full pickup i have done, it seemed like a relativly easy thing to do at first. Now i'm not so sure :)

legacy-Mr Evil
05-22-2003, 02:26 PM
You picked a hard one to start out with! As you have already discovered, UDamage is hard-coded in the Pawn class (/me slaps wrist of whoever wrote it) making it very difficult to alter.

You may be able to make it work by forgetting about subclassing the standard UDamage and making your own instead which changes the Pawn variable DamageScaling. I suspect it may not be that easy though, otherwise it would be done that way already.

Mysterial
05-22-2003, 03:18 PM
Originally posted by Mr Evil
You may be able to make it work by forgetting about subclassing the standard UDamage and making your own instead which changes the Pawn variable DamageScaling. I suspect it may not be that easy though, otherwise it would be done that way already.

Actually, I'm pretty sure the reason they hacked in UDamage in Pawn is for the weapon skin, so the rest shouldn't be that hard.

legacy-KillBait!
05-22-2003, 03:43 PM
Originally posted by Mr Evil
You picked a hard one to start out with! As you have already discovered, UDamage is hard-coded in the Pawn class (/me slaps wrist of whoever wrote it) making it very difficult to alter.

And i just discovered the damage bar that shows the time left before the pickup runs out won't display properly if the time isn't 30 seconds, seems that is hard coded aswell :eek:


You may be able to make it work by forgetting about subclassing the standard UDamage and making your own instead which changes the Pawn variable DamageScaling. I suspect it may not be that easy though, otherwise it would be done that way already.

That sounds way out of my skill range at the moment :) , i like a challange, but i'm about ready to give up and try something else :)

seeing the comment in the code '// FIXME THIS SUCKS' didnt give me a lot of hope.

Thanks muchly for the help anyway.

legacy-DragonRider
10-06-2003, 08:03 AM
I'm a noob but I got Triple Damage working and in my code I have the modifier in there so you just change the number to something that will give you what you want...

ONE THING THOUGH... It does varying damage for some reason. One shot it could be 50 the next 54 and the last 48... But they always hover in the same general area.. But its not a solid number...

If you'd like my code you can contact me via messenger's and I'll exchange it for your actor replacement code ;) I want a mutator that spawns triple damage always as one, and another that does it only like 25% of the time :D

(AIM: Sekioh, MSN: Riley_Clifford@hotmail.com, ICQ: 83670282, YAHOO: Cliffwr)

legacy-Bonehed316
10-10-2003, 02:00 PM
ah, yes, lol. ive tried the tripple damage before as well. i think mr evil is right, though. subclassing udamage is pretty useless, except that it turns on the udamage overlay, etc. all you would need to do is set a function that, when you have the udamage, your damagescaling =* 1.5. 2(1.5) = 3. that is where i got stuck, long ago. it never worked, actually. or it worked, and never turned off, lol. probably something simple, too.

legacy-DragonRider
10-12-2003, 03:17 PM
Yep... Simple... on a complex level xD

Well I just Enabled UDamage and multiplied by 1.5... Then I set a timer for the same time UDamage wears off and told it to divide by 1.5.... Still gots bugs and I'll probably recode it some other day but right now I'm going to finish up the primary stuff and make it available to public...

Gimme another 7 days and I'll have a Beta out for you... (as of now I have the pickup and the mutator working fine in the idea of it replacing ALL Double Damage on startup... still working on the code to swap back and forth or intercept a spawning)

legacy-DragonRider
10-12-2003, 03:45 PM
Forget 7 days... Heres a simple beta trimmed down for everyones use... Adster says that the bots don't recognize it currently but thats a bug for later... I haven't tried different time other than 30 seconds... I'll look into that...

[Triple Damage] (http://www.b5-blender.com/temp/dragonrider/Triple Damage.ut2mod)

legacy-the Adster
10-12-2003, 07:14 PM
Just downloaded and tested the cutdown mutator, it seems to be heading in the right direction at the moment.

I'll send you a private mail with more detailed comments as soon as I've posted this, you haven't replied to any of my recent mails but after seeing your post here it does mean you are still alive, and working on Triple Damage.

legacy-Bonehed316
10-12-2003, 07:29 PM
lol, see, you have the same problem i did. sure, you can scale the damage by 1.5, but guess what? after the double damage has worn off, you cant set it back to normal. i believe the problem is you cant have more than one timer on an object at once. so making a new timer is useless.

legacy-the Adster
10-12-2003, 07:41 PM
I'm trying to offer help to DragonRider on the mutator, I've managed to solve ALL the problems with the timers/damage scaling/respawn wait/duration of use but have an issue with the actual pick-up.

When I test the mutator with a test level (available here: http://www.speakerprojects.com/computers/addons/dm-triple.ut2) I can only pick the Triple Damage relic once, after that it doesn't respawn (from the WildCardBase I can pick relics up as often as they appear until I grab a TD relic, after which nothing else is spawned). Does anyone else have the same issue? If not, which maps have you been using?

legacy-Bonehed316
10-12-2003, 07:49 PM
im not using the mutator, but my own. ive looked over his source, and he has done, at last check, nearly exactly what i did.

ive tried many things, even not using a timer. a while statement crashes the game, so thats out of the question. my only problem is that the damage scaling wont turn off. but im also using a placable actor that i put into a test map.

if youre tripple damage pickup is subclassed under the tournament pickup, theres a default property for RespawnTime=90.000000 for the udamage. you may want to consider adding this back in to your source. it looks like it was removed.

legacy-the Adster
10-12-2003, 08:22 PM
Bonehed316:
Currently DragonRider and myself have two different versions of the mutator under development, to see what each can come up with. Since his replace code is so much shorter that mine (mine runs to about 50+ lines because of all the extra setup stuff I get the mutator to do) I was just curious to see how effective it actually is.

If you've not run the mutator you won't be able to answer my question about TD relics not respawning after collection.

As for the RespawnTime issue; this is not what's causing relics to not respawn, but how a Charger (be it a UDamageCharger, a WildCardBase, or what ever) knows when the current pick-up floating above it has been collected. Without putting you to sleep, when a Charger spawns a relic it tells the relic who owns it and stuff like that (about an hours worth of reading to pin down exactly what happens). By intercepting the creation of relics in the way DragonRider does it means the new TripleDamagePickup (TD relic) isn't tied to anything, so when it's collected the Charger just sits there as if nothing happened and never spawns anything else.

It would appear that I've just answered my own question about why things stop working, but with only my own two machines to play on it could conceivably be something to do with my setups (I doubt it, but who knows).

legacy-Bonehed316
10-12-2003, 11:02 PM
well, okay. then it appears that the mutator is whats causing the problem. but, then, how do custom weapons respawn? my pickup respawns just fine.

my point is that his tripledamage extends tournament pickup, which has in its default properties respawn time. but within his code, this setting is not there. he has, however, respawnwait, which should, in theory, work like this:

under default properties, set RespawnTime=RespawnWait. that, at least in my not-very-good-at-uscript-mind should work.

otherwise, you may want to investigate what makes weapons able to be replaced and still spawn properly.

legacy-the Adster
10-13-2003, 03:37 AM
I'd not considered weapons in my equation (should function in the same way but I'll look into it), this is because I've not done any replacement work with them in UT 2003 just yet. In the original UT they were just stand-alone pick-ups, no need to get involved with Chargers so the intercept call in CheckReplacement was all that was needed.

You said you were using a placeable actor for your project, what do you mean by this? Do you get involved with Chargers, or is it simply an appear once relic?

legacy-Bonehed316
10-13-2003, 03:47 AM
i just copied the UDamageCharger class, renamed it, and it works. respawns and everything.


//================================================== ===========================
// TrippleDamageCharger.
//================================================== ===========================
class TrippleDamageCharger extends xPickupBase;

defaultproperties
{
PowerUp=Class'Tripple.TrippleDamagePack'
SpawnHeight=60.000000
DrawType=DT_StaticMesh
StaticMesh=StaticMesh'XGame_rc.ShieldChargerMesh'
Texture=None
}

works fine, lol. of course, i havent checked it online, no network in my home.

but then again, ive never gotten the pickup to work right. i can get it to take the right amount of damage, but turning off damage scaling has proven too much for me, lol. i dont try harder because i simply dont need it anymore.

legacy-the Adster
10-13-2003, 04:12 AM
The secret to getting the damage scaling to turn off is to subclass timer and intercept the call to create a UDamageTimer, you don't stop the UDamageTimer from running as otherwise the purple glow effect will stay on forever. Instead, you create an instance of the new timer that has the same settings as the UDamageTimer (duration, owner and so on) and tell that to adjust the player's damage scaling when it runs down (goes off).

As you correctly pointed out earlier, you can only have one type of timer running per controller so to get round this I simply prohibit players from collecting more than one damage amplifier at a time. This also stops players from being greedy when it comes to the pick-ups, they can only carry one at a time, allowing others to get some damage scaling applied to their weapons.

legacy-the Adster
10-14-2003, 06:25 AM
Originally posted by Bonehed316
well, okay. then it appears that the mutator is whats causing the problem. but, then, how do custom weapons respawn?

I've been looking into this and and the only way to do it is to change the pickup type of the xWeaponBase relating to the weapon you want to replace to the new custom weapon pickup.

Example:


function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
{
if ( (xWeaponBase(Other) != None) && (xWeaponBase(Other).WeaponType == class'XWeapons.RocketLauncher') )
{
xWeaponBase(Other).WeaponType = class'MyWeapons.MyRocketLauncher';
return false;
}
}

legacy-DragonRider
10-14-2003, 11:35 AM
I don't know what happened but I DID have it return to normal AND respawn once before... Then I started messing with it trying to get the 'swapout' code to work... thats where it started getting messy... I'm going to look over the original code I had and see if I can see the problem...

and it looks like you recommended I use:

DefaultProperties
{
RespawnTime=RespawnWait
}
The thing is... I HAVE it like that... but its not reading the variable with the number... so its setting it to a wacky number like -1 or a text which of course wouldn't work... Adster seems to have figured out a way to make it a editable variable in the actual code itself...
RespawnTime = MutTripleDamage.default.RespawnWait;

And the reason for the not disabling the damage modifier I THINK is because I'm using a timer in the pickup itself, and the pickup destroy's itself before/at the same time as the timer tries to execute, so it doesn't get to run through the code... I'm trying to use the Spawn'TripleDamageTimer' method now and see if that changes anything... Again... looks like Adster beat me to it :cry:

Oh well... I'll continue posting updates everytime I get a semi-operational comile going (as in the menu really works instead of pointing to a dummy class :P)

legacy-the Adster
10-15-2003, 12:38 AM
Let's hear it for the Adster! What a top-quality geezer.

(Of course, I'm using my sarcastic voice, which I've been told sounds a lot like my regular voice ;))


Originally posted by DragonRider
And the reason for the not disabling the damage modifier I THINK is because I'm using a timer in the pickup itself, and the pickup destroy's itself before/at the same time as the timer tries to execute, so it doesn't get to run through the code... I'm trying to use the Spawn'TripleDamageTimer' method now and see if that changes anything... Again... looks like Adster beat me to it

I didn't beat you to it DragonRider as I thought we were cooperating on this mutator so there's no 'race' aspect as far as I'm concerned, unless we're now spelling team with an I.

legacy-DragonRider
10-15-2003, 02:58 PM
I really don't care... But I'd have liked to solve the pickup itself at least... I DO need the help with the Bot pathing type stuff as you say is a arisen problem...

legacy-the Adster
11-13-2003, 01:05 AM
How much further have you got with the Triple Damage project?

I've just written No Invisibility so have some more spare time to devote to this project. I've been thinking about how to get the pickup to switch between Triple and Double damage and I think the best way would be to decide which one to spawn and then use the Transmogrify function (or one similar) from the TripleWildCardBase to change it if need be. The Double damage would need to be one of our custom types, this is so we can control what happens to it when it's picked up.

Let me know what you think.

legacy-DragonRider
11-13-2003, 12:13 PM
I haven't had much time to work on it but its still being worked on, just slowly. Gots lots of projects here to do other than just this. Not to mention school, and other real life matters :P

legacy-the Adster
11-15-2003, 06:28 PM
I've been banging away on the keyboard again and I've just about finished working on the swap-out code (making it possible to spawn a Triple or Double damage, depending on the AppearChance). Just need to do some testing with WildCardBases first (doesn't seem to switch pickups correctly).

I've also added the feature of being able to drop relics if a player is killed while carrying a damage amplifier, you can stop this through the config window if you don't like it.

I'll post again soon.

legacy-the Adster
11-16-2003, 02:02 PM
The bots go nuts for the Triple (or Double) damage pickup, even more than for the regular UDamagePack.

The config screen now allows the user to spawn only Doubles or Triples, or a mixture of both (depends on the AppearChance setting). Just need to fix the drop relic code as it only works for humans at the moment, I should have this done today (hopefully by the time I finish this glass of nice red wine [Gosh, that does make me sound old doesn't it]).

When I've finished I'll mail the UC files et al to you (as promised, I don't intend to release this mutator to the public. It will always be running on the Castle server though, so it will eventually get out there as clients log on and play). Everything you will need to know about the mutator's workings has been included in the ReadMe, feel free to change it, I just wanted to get the information to you on how to operate the thing.

legacy-the Adster
11-16-2003, 09:16 PM
To finish this mutator it took:
Two more glasses of red wine
A Steak dinner
A couple of blunts
Back to the Future (DTS) on DVD

I'll mail the files as soon as I've posted this.

legacy-DragonRider
11-18-2003, 12:27 PM
The bot thing should be fixable by changing the botdesirability variable in the pickup I think... I put it up like .2 more when I first designed it since I DID want them to fight with you over it to make it like the double damage where you'll be lucky if you get to it first.

legacy-the Adster
11-18-2003, 01:42 PM
The code I sent to you can be modified in any way you see fit, making the Triple/Double damage more or less desirable as you see fit. As far as I know (AFAIK) there are no serious bugs in the code (none at all that I could spot, and I've left the game running for over two hours while I was out), if I discover any I'll send the 'fix' to you. Otherwise, I don't intend to touch the code again, since it works and I'm not releasing it (other than running it on the Castle server).

You might want to remove some of the Log lines before you publish Mega Stuff, as a lot of them have been included in case you want to modify the code (the comments in the Log provide an indication of what bits of code have been executed).

legacy-DragonRider
11-18-2003, 05:13 PM
I compiled and have two seperate zipped files (source + compile) one is the way you sent me and the other is half the size (shaved 15kb off the filesize) by removing Log lines and comments.

I checked 3 respawn waitings and with 50% appear chance I got only TripleDamage, no Double showed up... Is it still too high with 50% to find a Double?

BTW... I noted you changed the texture ;-D A2597 a friend says it looks like the original UT's now...

legacy-Bonehed316
11-18-2003, 05:34 PM
that depends on how youre coming up with the %. to make it a truly random percentage, you might try an array with an index of 100, and fill the elements of the array with number of the chance% tripple damage, and the rest with double. (0 or 1)

for (x=0;x<chance;x++)
array[x] = 0; //fills the array with the chance number of tripple damage

for(x=chance;x<100;x++)
array[x] = 1; //fills the rest of the array with double damage

another way may be to simple be sure that the array is initialized as 0, and set the chance% of them to 1, and let the rest stay 0. saves a bit of cpu time.

then set whether or not it will be double damage to a random element in the array

SomeVariable = array[rand(100)];

remember that rand() finds a random number between 0 and index-1. so between 0 and 99, the same values as the array holds.

it will then choose a random element of the array, and set the pickup to be whatever mode it held.

that at least is one way i could think to do it, i think, lol. you may have a better solution.

legacy-DragonRider
11-18-2003, 06:15 PM
We used pretty much the method the UT2003's mixed spawn point... Like where it spawns Shield, DoubleDamage, and Keg of Health. Something along that lines, I don't feel like looking it up right now, I'm just not sure Adster wrote the Config menu so that it interacts fully, or we didn't do the correct amount for the rand.

legacy-the Adster
11-18-2003, 07:10 PM
The AppearChance works like this:
[list=1]
Replace all UDamagePacks with a TokenPickup (check xPickupBases and WildCardBases)
Spawn a TokenPickup (controlled by the PickupBase)
The TokenPickup decides which type of relic to spawn based on AppearChance
[/list=1]

Using this method ensures the AppearChance is applied on a 'per spawn' basis, it does mean that you could never see a Triple or Double relic during a game but without being able to predict how many relics will be spawned there's nothing more you can do. The odds of a relic appearing is like tossing a coin; the outcome of a toss never depends on any of the previous results. On average you will get a roughly 50-50 split between heads and tails, but when we did it at school it was 53% heads and 47% tails (I know it was many years ago, but it stuck in my mind precisely because it wasn't 50-50).

The AppearChance is used in the following way:

From TokenPickup.uc
===================
function SwitchPickup( )
{
..
..Some code. Not needed for this example.
..
AppearValue = class'MutTripleDamage'.default.AppearChance;
if( AppearValue < 10 )
{
SpawnChance = Rand( 10 );
Log( "This is the AppearChance value in percent:" @SpawnChance$ "0%", 'MEGA STUFF' );

if( SpawnChance < AppearValue )
{
Log( "TokenPickup: T R I P L E D A M A G E!", 'MEGA STUFF' );
NewRelic = spawn( class'MegaStuff.TripleDamagePickup', , , Location );
NewRelic.OurBoss = self;
NewRelic.Event = Event;
if( PickupBase != None )
{
Log( "TRIPLE Token has a base", 'MEGA STUFF' );
NewRelic.PickupBase = PickupBase;
NewRelic.PickupBase.myPickup = NewRelic;
NewRelic.PickupBase.myMarker.markedItem = NewRelic;
NewRelic.PickupBase.myMarker.ExtraCost = PickupBase.ExtraPathCost;
NewRelic.PickupBase.myPickup.myMarker = PickupBase.myMarker;
}
NewRelic.AddToNavigation( );
}
else
{
Log( "TokenPickup: D O U B L E D A M A G E!", 'MEGA STUFF' );
NewRelic = spawn( class'MegaStuff.DoubleDamagePickup', , , Location );
NewRelic.OurBoss = self;
NewRelic.Event = Event;
if( PickupBase != None )
{
Log( "DOUBLE Token has a base", 'MEGA STUFF' );
NewRelic.PickupBase = PickupBase;
NewRelic.PickupBase.myPickup = NewRelic;
NewRelic.PickupBase.myMarker.markedItem = NewRelic;
NewRelic.PickupBase.myMarker.ExtraCost = PickupBase.ExtraPathCost;
NewRelic.PickupBase.myPickup.myMarker = PickupBase.myMarker;
}
NewRelic.AddToNavigation( );
}
}
..
..Some code. Not needed for this example.
..
}
A random number between 0 and 9 is created and assigned to SpawnChance. If SpawnChance is less than AppearChance a Triple Damage relic will be spawned, otherwise a Double Damage relic is produced. As stressed before, this is the 'best' way to work out the chance of a relic appearing but does mean you could go through a lean patch of one type of pickup (computers are not known for their random capabilities so you just have to accept this limitation).

I've just come home from work early after a crash with another fork-truck (completely not my fault I hasten to add) but I did spot a 'bug' with the code. It's not a fatal fault, just that trying to pick up two damage amplifiers doesn't result in a warning to the player. I've got a pretty good idea of how to fix this so I'll post as soon as I've 'fixed' it.

legacy-the Adster
11-18-2003, 07:22 PM
Originally posted by DragonRider
I'm just not sure the Adster wrote the Config menu so that it interacts fully, or we didn't do the correct amount for the rand.

What? Eh? Interacts with what?

The config screen works 100%. If you run UT 2003, change some of the settings and then look in MegaStuff.INI you'll see the settings mirrored exactly as they should be. Getting configs recorded properly is one of the most time consuming parts of a project, in fact one of my latest mutators has more code in the config UC than in the mutator.

I'm not sure what you were driving at with your last post DragonRider, but I think you should look at how true chance works (my last post contains a mini-rant on the subject, not a complete argument, but enough to illustrate my point).

legacy-the Adster
11-18-2003, 08:15 PM
DragonRider:

Fixed it. Just had to move part of an 'if' statement, and change the 'else' condition. Tested in online, all seems well. Increased the version number to 1.1 in all concerned files and mailed them to you. There was also some testing 'junk' still hanging around so I cleaned that out too.

The files changed are:
MutTripleDamage.UC
TripleDamagePickup.UC
DoubleDamagePickup.UC
MegaStuff.INT
MegaStuff.TXT


If you plan to use my code as a template for further development you should check your versions of the above files to see what changes were made. Most of them are subtle so be careful, there are file comparison programs available that will make light work of this task. I can mail you one if you want.