Aller au contenu

Photo

if statement checking tag?


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
ToasterCrumb

ToasterCrumb
  • Members
  • 10 messages

I've fleshed out some of my own custom xp/gold system for OnDeath, but I would like to make custom drops as well. Specifically a drop system where I hand select the items that certain creatures drop.

 

I can't think of a way to check in an if statement -IF- the creature killed, is in fact "THIS_TAG"

 

Trying to make it so -IF- (OBJECT_SELF) == "THIS_TAG" THEN

 

There will be other checks in there, of course.

 

 

Maybe switches will work?? I have yet to look into those.

 

So one more time.

 

I really have no idea what I'm doing. lol. I know my scripts are inefficient and messy, but a lot of them work for what I need. :-)

 

EXAMPLE:

int nRare = Random(65) + 1;
                 //oCreatureKilled is the OBJECT this OnDeath script is attached to.
if (oCreatureKilled == "THIS_TAG" && nRare == 64 && whateverelse == TRUE)
  GiveThisAwsomeShinyWeapon; //or maybe spawn in as loot on the corpse?
}


#2
Tchos

Tchos
  • Members
  • 5 030 messages

If you use the default scripts, or insert the appropriate code from the default scripts, you can do that with the built-in SoZ loot system.  You can just put a local variable on the creature(s) with a list of resrefs of the items you want them to drop, with a percentage chance (can be 100% if you want).  It also supports two separate lists with different drop percentage chances, and also allows you to have them stop dropping the special items after the player has gotten enough of them.  I wrote a guide for it.

 

http://www.nexusmods...inter2/mods/273

http://neverwinterva...hir-loot-system


  • GCoyote et ColorsFade aiment ceci

#3
ToasterCrumb

ToasterCrumb
  • Members
  • 10 messages

Cool! I'll take a look at those right now. :-)



#4
Tchos

Tchos
  • Members
  • 5 030 messages

Something that I would add to the guide now that I've used the system for some time is that it helps to save variable sets (from the properties palette, "Import properties" / "Export properties") so that you can have numerous premade random loot sets that you can start with as a base, adding or removing loot from there without having to add each variable individually.  In my campaign, I made several random loot lists for different creatures and classes based on what they would likely be carrying, and saved those as variable sets that could be imported easily to any creature that I hadn't already made into a customised blueprint.


  • GCoyote et ColorsFade aiment ceci

#5
ColorsFade

ColorsFade
  • Members
  • 1 267 messages

If you use the default scripts, or insert the appropriate code from the default scripts, you can do that with the built-in SoZ loot system.  You can just put a local variable on the creature(s) with a list of resrefs of the items you want them to drop, with a percentage chance (can be 100% if you want).  It also supports two separate lists with different drop percentage chances, and also allows you to have them stop dropping the special items after the player has gotten enough of them.  I wrote a guide for it.

 

http://www.nexusmods...inter2/mods/273

http://neverwinterva...hir-loot-system

I am totally going to have to check that out... 



#6
ToasterCrumb

ToasterCrumb
  • Members
  • 10 messages

After spending some time fiddling around, I have an idea that I will try. If it works, awesome, if not, I will probably use this system.



#7
Tchos

Tchos
  • Members
  • 5 030 messages

I liked the SoZ system so much, I adapted it to also work on placeables with just 1 or 2 additional scripts in my campaign (which you can also use if you like).  It's very flexible.



#8
ToasterCrumb

ToasterCrumb
  • Members
  • 10 messages

After I had poked around a bit -- I think I discovered a solution to my needs.

 

I do think the SoZ system has great potential. And I'll probably use it if my system hits a wall -OR- I get better with scripting and upgrade to something that can easily be modified. :-)

 

Thank you, Tchos.

_____________________________________________________________________

 

I was overlooking strings and how they can be used.

 

I didn't realize I could do something like this:

 

EXAMPLE:

    int nCommon = Random(5);
    int nUncommon = Random(25);
    int nRare = Random(65);
    int nVeryRare = Random(129);
    int nArtifact = Random(257);

    if (GetResRef(OBJECT_SELF) == "CreatureRR" && nRare == 0 && WhatEverElse() == TRUE)
        GiveOrDoWhatever();
}

Using the string in an 'if' statement like that ("tag_or_rr")


  • GCoyote aime ceci

#9
Tchos

Tchos
  • Members
  • 5 030 messages

The reason I didn't go into any detail about the use of an IF statement is that it's generally not done that way for what you're doing.  You could put all of that code that's inside the IF statement and make it specific to the individual creature, use the standard On Spawn script, and add a local variable to each individual creature type's blueprint called SpawnScript, and have a different script for each creature that spawns different things, or have it read a second local variable with the stuff you want it to have in its inventory.  But that's not to say it wouldn't work the way you're doing it.  I just find it more flexible personally the other ways.  Your way does have the advantage that you could just have one script for all creatures, and add new conditions to it any time you add another creature type.



#10
ToasterCrumb

ToasterCrumb
  • Members
  • 10 messages

Yep. I know the way I'm doing things aren't ideal, but I don't have enough experience to pull off what I really want.

 

Which is why I'm considering what you showed me.

 

However, if I don't mess around and fail hard, I won't learn. I'm doing much better than when I tried this several years ago.

 

Perhaps the few chapters I had read in C++ Primer Plus made this a bit easier to understand. That was also a several years ago.

 

 

 

I should crack that book open again -- it wasn't too difficult to understand.

 

EDIT: I think I'll settle for a hybrid of what I have going and the SoZ.