[Logo]
 
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Code for stopping AMs from dropping artifacts  XML
Forum Index -> Druids RPG Go to Page: 1, 2 Next 
Author Message
BotFodder

Wicked Sick!
[Avatar]

Joined: 01/13/2006 15:23:41
Messages: 1239
Location: Florida
Offline

Okay - mind you that this would be my first attempt at writing UnrealScript stuff. And I haven't actually put this into anything and tried to compile it ... but ...

Dru and I discussed in PMs the whole idea of getting just AMs to stop dropping artifacts on death. As you'll see, there are comments in the code containing questions that, if you know the answers to, I'd like to know. Where this code would go into place is basically into any artifact that you wouldn't want to spill out of an AM when they died. This code should (if I wrote it anywhere near correctly) allow all other classes to throw on death the artifact in question. It should also allow an AM to toss the artifact while still alive.

The gotchas are probably many - one of which that just occurred to me:

If you wanted to allow an AM to drop on death an artifact they picked up (IE, they threw the one they started with, but then picked up the same one later), this wouldn't allow that.

Please review and critique. I'm learning here ...

Code:
function DropFrom(vector StartLocation)
 {
 	local int x;
 	local bool ok;
 	local RPGStatsInv StatsInv;
 
 	if (bActive)
 		GotoState('');
 
 // All this is for finding out if the class of the player is AM.
 	StatsInv = RPGStatsInv(Instigator.FindInventoryType(class'RPGStatsInv'));
 	if(StatsInv != None)
 		for (x = 0; x < StatsInv.Data.Abilities.length && !ok; x++)
 			if (statsInv.Data.Abilities[x] == class'ClassAdrenalineMaster')
 				ok = True;
 
 // Now, depending on state of player and class:
 	if (Instigator.Health <= 0 && ok)
 	{
 		Destroy();
 // If we're talking dead people, do we really need this?  It depends on
 // what "NextItem" really means ... if it's just changing the active
 // item for a living person, then we don't need this.  And there's a part of
 // me that seriously wants to see this *before* Destroy() - must be a hold
 // over from my LPC days.
 		Instigator.NextItem();
 	}
 	else
 	{
 // If "tossed", NextItem is called in TossArtifact function, BUT:
 // if "NextItem" needed for dead people, it's needed somewhere here.
 // However, that may be handled in "Super.DropFrom".  Or, would this
 // possibly result in only the active item being dropped from non-
 // adrens?
 		Super.DropFrom(StartLocation);
 	}
 }

Dru mentioned that this solution is a bit inflexible - it can cause problems for folks that wish to extend his code. I would guess the exact reason for that is the limitations of UnrealScript's inheritance (which I haven't quite gotten a grip on, but on some level understand)? Is it because they'd be unable to reference Mysterial's version of the artifact while using/referencing any part of Dru's mod (if Dru's mod used artifact classes that contained the above code snippet)?

Would it be possible to set up the RPG INI to use either Dru's version of a particular artifact, or Mysterial's? I would think so IIRC what I've seen in the INI. Server owners could still mix and match, right? It's just the "extenders" that are going to run into problems?

I use the Futurama Prof. Farnsworth Skin: http://www.disastrousconsequences.com/dcforum/posts/list/1595.page
WM: (DC)BotFodder 170
MM: (DC)BotDoctor 141
AM: (DC)BotBooster 147
http://ericdives.com/ - My DC Newbie FAQ: http://tinyurl.com/lz229
Twitter: http://twitter.com/ericdives
[WWW] aim icon [MSN]
BotFodder

Wicked Sick!
[Avatar]

Joined: 01/13/2006 15:23:41
Messages: 1239
Location: Florida
Offline

Also, would it be worth rewriting such that the "death" check occurs first (and if not dead, then just allow the throwing), and the class loop is not checked unless Instigator is dead?

I use the Futurama Prof. Farnsworth Skin: http://www.disastrousconsequences.com/dcforum/posts/list/1595.page
WM: (DC)BotFodder 170
MM: (DC)BotDoctor 141
AM: (DC)BotBooster 147
http://ericdives.com/ - My DC Newbie FAQ: http://tinyurl.com/lz229
Twitter: http://twitter.com/ericdives
[WWW] aim icon [MSN]
BotFodder

Wicked Sick!
[Avatar]

Joined: 01/13/2006 15:23:41
Messages: 1239
Location: Florida
Offline

Well, I guess everyone is ignoring this ...

Dru, would it be worth anything to you if I took this code, changed it in DruidsRPG200, and tested it "locally"? (I've gotten 200 running on my home box as a "listen" server).

I use the Futurama Prof. Farnsworth Skin: http://www.disastrousconsequences.com/dcforum/posts/list/1595.page
WM: (DC)BotFodder 170
MM: (DC)BotDoctor 141
AM: (DC)BotBooster 147
http://ericdives.com/ - My DC Newbie FAQ: http://tinyurl.com/lz229
Twitter: http://twitter.com/ericdives
[WWW] aim icon [MSN]
kyraeu

Rampage
[Avatar]

Joined: 08/20/2005 18:13:53
Messages: 110
Location: Edmonds, WA
Offline

I didn't ignore it... I just chose not to comment.

Reading through the code, I guess it would work. I would very much like not being a pinata whenever that shield nali comes up behind me, so I hope it works too... just without the errors it had before. I might be willing to help test it - but I'm sure there are others who could help ya more.

Hope it works!

My Players: Junkie: Kyraeu 85 -- Medic: Excuses 68 -- Weapon: Fyruse 40
Saving for: Ghost 1, 2, 3, then adren skills -- Ghost 3 -- max DB, then some HB
Szlat

Wicked Sick!

Joined: 05/18/2005 18:32:41
Messages: 2124
Location: UK
Offline

BotFodder wrote:
Also, would it be worth rewriting such that the "death" check occurs first (and if not dead, then just allow the throwing), and the class loop is not checked unless Instigator is dead? 

Yes
Szlat

Wicked Sick!

Joined: 05/18/2005 18:32:41
Messages: 2124
Location: UK
Offline

BotFodder wrote:
Okay - mind you that this would be my first attempt at writing UnrealScript stuff. And I haven't actually put this into anything and tried to compile it ... but ...

Dru and I discussed in PMs the whole idea of getting just AMs to stop dropping artifacts on death. As you'll see, there are comments in the code containing questions that, if you know the answers to, I'd like to know. Where this code would go into place is basically into any artifact that you wouldn't want to spill out of an AM when they died. This code should (if I wrote it anywhere near correctly) allow all other classes to throw on death the artifact in question. It should also allow an AM to toss the artifact while still alive.

The gotchas are probably many - one of which that just occurred to me:

If you wanted to allow an AM to drop on death an artifact they picked up (IE, they threw the one they started with, but then picked up the same one later), this wouldn't allow that.

Please review and critique. I'm learning here ...

Code:
function DropFrom(vector StartLocation)
 {
 	local int x;
 	local bool ok;
 	local RPGStatsInv StatsInv;
 
 	if (bActive)
 		GotoState('');
 
 // All this is for finding out if the class of the player is AM.
 	StatsInv = RPGStatsInv(Instigator.FindInventoryType(class'RPGStatsInv'));
 	if(StatsInv != None)
 		for (x = 0; x < StatsInv.Data.Abilities.length && !ok; x++)
 			if (statsInv.Data.Abilities[x] == class'ClassAdrenalineMaster')
 				ok = True;
 
 // Now, depending on state of player and class:
 	if (Instigator.Health <= 0 && ok)
 	{
 		Destroy();
 // If we're talking dead people, do we really need this?  It depends on
 // what "NextItem" really means ... if it's just changing the active
 // item for a living person, then we don't need this.  And there's a part of
 // me that seriously wants to see this *before* Destroy() - must be a hold
 // over from my LPC days.
 		Instigator.NextItem();
 	}
 	else
 	{
 // If "tossed", NextItem is called in TossArtifact function, BUT:
 // if "NextItem" needed for dead people, it's needed somewhere here.
 // However, that may be handled in "Super.DropFrom".  Or, would this
 // possibly result in only the active item being dropped from non-
 // adrens?
 		Super.DropFrom(StartLocation);
 	}
 }

 

I have only had a quick scan through what you have suggested, but it all looks quite reasonable.
in the bit where you check if (bActive), I would set bActive to be false.
I would also check for DruidArtifactLoaded rather than ClassAdrenalineMaster
But it looks ok to me.

BotFodder wrote:
Dru mentioned that this solution is a bit inflexible - it can cause problems for folks that wish to extend his code. I would guess the exact reason for that is the limitations of UnrealScript's inheritance (which I haven't quite gotten a grip on, but on some level understand)? Is it because they'd be unable to reference Mysterial's version of the artifact while using/referencing any part of Dru's mod (if Dru's mod used artifact classes that contained the above code snippet)? 

Not sure what Dru is getting at here. You could make it configurable in the RPG.ini file to allow these artifacts to be dropped or not. Have a flag, and only check your classes code if the flag is set.
So, at the top of each artifact have
Code:
var config bool bAllowDrops;

and in the defaultproperties section
Code:
bAllowDrops=false

then put the test Code:
if(!bAllowDrops)
before doing your class search.
Then you can set the value of bAllowDrops in the RPG ini file.
However, these changes will not affect artifacts that Druid hasn't written. So if someone used Mysterials triple, or somebody else's megablast artifact, those artifacts wouldn't have the code in, and so would still drop. Still, they could always copy your code!
But that is all minor stuff. What you have there looks ok to me. Try editing it in and compiling. However, remember to save your proper DruidsRPG200.u so you can put it back later.

BotFodder wrote:
Would it be possible to set up the RPG INI to use either Dru's version of a particular artifact, or Mysterial's? I would think so IIRC what I've seen in the INI. Server owners could still mix and match, right? It's just the "extenders" that are going to run into problems? 
Yes, that is always possible. In the list of Artifacts they either list Druids or Mysterials.
BotFodder

Wicked Sick!
[Avatar]

Joined: 01/13/2006 15:23:41
Messages: 1239
Location: Florida
Offline

Szlat wrote:
I have only had a quick scan through what you have suggested, but it all looks quite reasonable.
in the bit where you check if (bActive), I would set bActive to be false.
I would also check for DruidArtifactLoaded rather than ClassAdrenalineMaster
But it looks ok to me. 

Yeah you know something itched me about that (bActive) sequence but I didn't look at it too closely. Thing is, I think it's practically verbatim from some of Dru's (and possibly Mysterial's) stuff.

As for what to look for, I guess I get it in theory - you could concievably (if someone didn't know what they were doing when they built their skills) have an AM without LA; any AM without LA would be treated as any other class, and drop artifacts on death.

Also, the code snippet could be backported (if someone so desired - doesn't sound appealing to me but you never know) to older (classless) versions of the mod.

Szlat wrote:
Not sure what Dru is getting at here. 

I think he means that if someone wanted to code extensions to his mod, they'd be stuck at a certain point having to use his code, or rewrite his mod to suit their needs. I think this has to do with the limits on inheritance in UnrealScript.

As far as testing this solution is concerned, I'm a weekend code warrior - during the week I've already done my 8 every day and want to just play. Also, I don't want to expend too much energy if it isn't eventually of use to someone.

If I do go about testing it, I will rewrite it to be a bit more optimized, and possibly include the suggested config.

I use the Futurama Prof. Farnsworth Skin: http://www.disastrousconsequences.com/dcforum/posts/list/1595.page
WM: (DC)BotFodder 170
MM: (DC)BotDoctor 141
AM: (DC)BotBooster 147
http://ericdives.com/ - My DC Newbie FAQ: http://tinyurl.com/lz229
Twitter: http://twitter.com/ericdives
[WWW] aim icon [MSN]
Szlat

Wicked Sick!

Joined: 05/18/2005 18:32:41
Messages: 2124
Location: UK
Offline

Another option would be to modify the DruidArtifactLoaded class. When a player is about to die, the code calls the PreventDeath function for each ability. So, we could add a PreventDeath function to the DruidArtifactLoaded class, which destroys the artifacts as the player is about to die. Then there is nothing to drop, and it works for any artifact.

However, it is possible that after PreventDeath is called for the DruidArtifactLoaded class, it is then called for another ability (e.g. Ghost) which decides you shouldn't die after all. Which would be a bit of a pain, because now you don't have the artifacts and you are still alive.

So, you would have to kick off a timer, that in a second could decide if you were not dead after all, and give you the artifacts back. Messy.

It would have been nice to put the destroy code in DruidArtifactLoadeds ScoreKill function, but unfortunately that is called after the artifacts have been dropped.

I suppose an alternative would be to let the artifacts be dropped, but kick off another object in the same location, which, one second later destroys all artifacts within a small radius. A bit like the ultima bomb, but no graphics and just takes out the artifacts.
EDIT: or sets the Lifetime of the artifact pickups to be less than a second. So, the artifacts are spawned, but not for long.
BotFodder

Wicked Sick!
[Avatar]

Joined: 01/13/2006 15:23:41
Messages: 1239
Location: Florida
Offline

Okay how about:

Hmmm ... perhaps there's a way to add code to either Ghost (to query if Ghost will or already has kicked in - but again you have to figure out the sequencing) or ArtifactLoaded to take care of the artifacts ... hmmm ...

I don't know how tightly intertwined Druid would want to make Ghost and another class. And I haven't poked around at the Ghost code yet. The thing is, I'm always one for simplicity in code, and this sounds like it would heavily complicate something somewhere along the lines ...

I use the Futurama Prof. Farnsworth Skin: http://www.disastrousconsequences.com/dcforum/posts/list/1595.page
WM: (DC)BotFodder 170
MM: (DC)BotDoctor 141
AM: (DC)BotBooster 147
http://ericdives.com/ - My DC Newbie FAQ: http://tinyurl.com/lz229
Twitter: http://twitter.com/ericdives
[WWW] aim icon [MSN]
Szlat

Wicked Sick!

Joined: 05/18/2005 18:32:41
Messages: 2124
Location: UK
Offline

You could add the code to Ghost, but what if someone replaced Druid's Ghost by their own Ghost? Or ran Mysterial's instead of Druid's Ghost?
So you can't rely on the code being there.

The simplest option is probably for the ScoreKill function of DruidLoadedArtifacts to set all artifacts in the immediate locality to have a LifeTime of 0.5 secs.
KohanX

Godlike

Joined: 03/04/2006 13:40:23
Messages: 350
Offline

Okay, I only read the first four posts or so, but to fix the 'picked up/loaded artifacts' difference, give the artifacts a boolean value, say, bAbilityInduced or something, and set it to true on each artifact you make using Loaded Artifacts. Then when you run this check you have created (good work, btw, you're learning a lot faster than did), you can check each artifact to see if it was picked up (or 'not ability-induced'), and if so, negate the stop-dropping effect.

Did you get all that? Seems sort of confusing to me as I read it... Good luck with your scripting .
BotFodder

Wicked Sick!
[Avatar]

Joined: 01/13/2006 15:23:41
Messages: 1239
Location: Florida
Offline

Kohan - it took me a while but I got it ...

And it's a very elegant solution. Except:

1. It doesn't avoid the problem with locking people in due to the inheritance limitations (if I understand even partially what Dru was getting at)

2. To get it to work, you either have to:

-1. Edit every object to work appropriately with the new variable, or

-2. The more elegant but possibly less desirable solution being to extend (or flat out rewrite) Mysterial's RPGArtifact class, which would probably cause you to rewrite all artifacts (which is what we'd be doing in any "change to nodrop" solution)

So really, there are any number of ways to deal with this situation - but it sounds like there are gotchas that Dru's not willing to deal with yet in pretty much any solution at the moment.

I use the Futurama Prof. Farnsworth Skin: http://www.disastrousconsequences.com/dcforum/posts/list/1595.page
WM: (DC)BotFodder 170
MM: (DC)BotDoctor 141
AM: (DC)BotBooster 147
http://ericdives.com/ - My DC Newbie FAQ: http://tinyurl.com/lz229
Twitter: http://twitter.com/ericdives
[WWW] aim icon [MSN]
Continuum

Wicked Sick!
[Avatar]

Joined: 03/09/2005 05:20:36
Messages: 479
Location: Indianapolis, Indiana
Offline

Since LA's are an additional class do they even need to get the default artifacts? You could give them an extended version that youve modified to prevent dropping (could even make an abstract class that they all extended from if you needed to).




Current WIP:
Skins:
[Email]
KohanX

Godlike

Joined: 03/04/2006 13:40:23
Messages: 350
Offline

Um, Bot, all you'd need to do is extend the RPGArtifact and add a single boolean value, with a default value of false... Then change LA to mark all its created artifacts...

Adn what's this about inheritance limitations?
BotFodder

Wicked Sick!
[Avatar]

Joined: 01/13/2006 15:23:41
Messages: 1239
Location: Florida
Offline

KohanX wrote:
Adn what's this about inheritance limitations? 

Actually rereading some stuff I've misunderstood a few things regarding "single inheritance" - and I don't think it has anything to do with the issue Dru apparently wants to avoid. But now I think I have a handle on it. I could be wrong - someone will please correct me if I'm grossly mistaken.

Dru seems (from what I can tell - which means I could be wrong) to be hesitant to lock people into certain things. Only he can tell you if I've misinterpreted what he's said to me. His concern appears to be that:

If someone wants to extend his mod (remember they'd be forced when using the DruidsRPG to use UT2004RPG), but Dru's mod extends (or are we talking purely in terms of "replacing" a base class? I dunno) something from Mysterial's mod, they would then have to either:

- Use the class as is in Dru's mod
- Extend the class in Dru's mod

What I can say with some confidence is that (according to Dru) they would not be able to extend the class from Mysterial's mod. I get the impression that once Dru creates a "base" class that overwrites/overrides Mysterial's, an extender cannot extend Mysterial's version, and has to deal with Dru's. Dru (or so it seems) does not want this. So if Dru did extend RPGArtifact, and someone wanted to use all of Dru's mod but extend Mysterial's version of RPGArtifact (and not at all deal with Dru's), they would not (not out of the box anyway).

(NOTE: the term "class" applies in terms of programming languages, not the implementation of "player classes", for those of you not in the programming frame of mind when you read this post)

I use the Futurama Prof. Farnsworth Skin: http://www.disastrousconsequences.com/dcforum/posts/list/1595.page
WM: (DC)BotFodder 170
MM: (DC)BotDoctor 141
AM: (DC)BotBooster 147
http://ericdives.com/ - My DC Newbie FAQ: http://tinyurl.com/lz229
Twitter: http://twitter.com/ericdives
[WWW] aim icon [MSN]
 
Forum Index -> Druids RPG Go to Page: 1, 2 Next 
Go to: