NPCs Recognizing Nakedness! Ahh!

Anonynn
12 Jan 2016, 20:42
Is there a way for the wearables library to incorporate this? Or a couple lines of code I could add to the NPC's to say something like...


If Player has no worn attribute, or recognizing the worn parameters like...

If player has no worn attribute in layer 2, or 3
then

Or something like that?

XanMag
12 Jan 2016, 21:03
Funny question! Can you just add a flag called naked to your player and then an if statement on your NPCs that responds how you want?

The Pixie
12 Jan 2016, 21:10
What Xan said, but it really should flag if certain areas are bare; wearng a hat and boots should (I guess) count as naked. Hmm, so I guess a flag on each garment as to whether it covers certain areas. May not be as simple as you might think.

Anonynn
12 Jan 2016, 23:00
Hmm....so let's say there is one pants.object, and one shirt.object.
In the wearables library, the "chest" and "legs" are covered; wear layer 2, 3

I go to the shirt.object
attributes, add
script
flag

something layer.....derp.

Maybe I should do this after I figure out how to do the cursed stuff >.>

The Pixie
13 Jan 2016, 08:45
I think the way I would do it is to have a function, say CheckClothingState, that tests if the player is naked or has certain areas exposed, and to set flags on the player object if they are. Call the function from the end of the DoWear and DoRemove functions. You can then test the flags in a text processor command.

CheckClothingState needs no parameters or return type, and would look a bit like this:
player.naked = true
player.barecrotch = true
player.barebust = true
foreach (o, GetDirectChildren(player)) {
if (GetBoolean(o, "worn")) {
player.naked = false
}
if (HasAttribute(o,"wear_slots")) {
if (ListContains(o.wear_slots, "chest")) {
player.barebust = false
}
if (ListContains(o.wear_slots, "crotch")) {
player.barecrotch = false
}
}
}

Make sure any garment that covers her chest has "chest" in the list of slots (looks like you already have), and "crotch" if it covers the crotch.

HegemonKhan
13 Jan 2016, 10:01
@ Pixie:

does quest have any 'break' (and~or 'continue' too) commands, so quest wouldn't have to (using your~Pixie's post's code help for neonayon as example) do the operations over and over of assigning, 'player.naked = false' and~or each of the individual body~equipment slots, for every clothing item ???

if not, would you have to use these code lines within a Function, using its 'return' to produce this result~effect of stopping the un-needed~redundant operations ??? Or is there some other code design way of doing this, that I'm going blank on at the moment (lol) ???

The Pixie
13 Jan 2016, 10:05
Quest has no break or continue (as far as I know anyway). You can break out of a loop with a return, as you say, but that is the only way. I am assuming the player inventory will not be that big, so the redundant looping will not be that much of a deal.

HegemonKhan
13 Jan 2016, 10:11
could a sentinnel 'while' loop somehow be designed to do this ?

(not sure if a 'foreach' and 'while' loop can be used together... if this would be the logic design to do this ~ I'm otherwise going blank on how to do the clothing items iteration, with or within, a 'while' loop argh, as I have had trouble with getting the 'while' loop to work on some other like-complex-stuff-for-me-anyways-lol, due to my lack of logic understanding, sighs).

The Pixie
13 Jan 2016, 11:40
You could do it with while, but the code would get messy. Generally (but not always) you are better going for clean code, because maintaining bad code will cost you more than the saving in computing time. Object-orientated programming was developed and gained popularity because the programs produced were easier for humans to understand and maintain (if you want fast, you use C).

Anonynn
13 Jan 2016, 21:28

I think the way I would do it is to have a function, say CheckClothingState, that tests if the player is naked or has certain areas exposed, and to set flags on the player object if they are. Call the function from the end of the DoWear and DoRemove functions. You can then test the flags in a text processor command.

CheckClothingState needs no parameters or return type, and would look a bit like this:

Code: Select all
player.naked = true
player.barecrotch = true
player.barebust = true
foreach (o, GetDirectChildren(player)) {
if (GetBoolean(o, "worn")) {
player.naked = false
}
if (HasAttribute(o,"wear_slots")) {
if (ListContains(o.wear_slots, "chest")) {
player.barebust = false
}
if (ListContains(o.wear_slots, "crotch")) {
player.barecrotch = false
}
}
}

Make sure any garment that covers her chest has "chest" in the list of slots (looks like you already have), and "crotch" if it covers the crotch.



Remember we altered the DoRemove code before. Here it is...

if (not object.parent = player or not GetBoolean(object, "worn") or not GetBoolean(object, "removeable")) {
if (object.removemsg = null) {
msg (DynamicTemplate("RemoveUnsuccessful",object))
}
else {
msg (object.removemsg)
}
}
else {
conflictedItem = null
// check if we are wearing anything over it
if (HasAttribute(object,"wear_slots")) {
foreach (item, ScopeReachableInventory()) {
if (HasAttribute(item,"wear_slots")) {
if (GetBoolean(item, "worn")) {
foreach (itemSlot, item.wear_slots) {
if (ListContains(object.wear_slots,itemSlot)) {
if (object.wear_layer < item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}
if (conflictedItem = null) {
if (object.removemsg = null) {
msg (DynamicTemplate("RemoveSuccessful",object))
}
else {
msg (object.removemsg)
}
object.worn = false
object.drop = object.original_drop
object.alias = object.original_alias
object.original_drop = null
object.original_alias = null
object.display = null
// do after
if (HasScript(object, "onafterremove")) {
do (object, "onafterremove")
}
else if (HasString(object, "onafterremove")) {
msg (object.onafterremove)
}
}
else {
msg (DynamicTemplate("RemoveFirst", conflictedItem))
}
}


So with that said, where would the new code be inserted in this old one? Would it still be at the end of this code? Like underneath this line...

msg (DynamicTemplate("RemoveFirst", conflictedItem))
}

?

And here is the DoWear code.

player.toobigforitem = false
if (HasScript(object, "testplayersize")) {
do (object, "testplayersize")
}
if (player.toobigforitem) {
if (HasString(object, "toobigtowearmsg")) {
msg (object.toobigtowearmsg)
}
else {
msg ("You try to put on the " + GetDisplayName(object) + " but it just won't fit!")
}
}
else if (not HasAttribute(object,"worn")) {
msg (DynamicTemplate("WearUnsuccessful", object))
}
else if (object.parent = player and GetBoolean(object, "worn")) {
msg (DynamicTemplate("AlreadyWearing", object))
}
else if (not ListContains(ScopeInventory(), object)) {
msg (DynamicTemplate("WearUnsuccessful", object))
}
else {
isLayerProblem = false
conflictedItem = null
if (HasAttribute(object,"wear_slots")) {
foreach (item, ScopeReachableInventory()) {
if (HasAttribute(item,"wear_slots")) {
if (GetBoolean(item, "worn")) {
foreach (itemSlot, item.wear_slots) {
if (ListContains(object.wear_slots,itemSlot)) {
if (object.wear_layer < item.wear_layer) {
conflictedItem = item
isLayerProblem = true
}
else if (object.wear_layer = item.wear_layer) {
conflictedItem = item
}
}
}
}
}
}
}
if (conflictedItem = null) {
object.worn = True
object.original_drop = object.drop
object.original_alias = object.alias
object.drop = false
object.display = GetDisplayName(object)
object.alias = GetDisplayAlias(object) + " (worn)"
if (object.wearmsg = null) {
msg (DynamicTemplate("WearSuccessful",object))
}
else {
msg (object.wearmsg)
}
// do after
if (HasScript(object, "onafterwear")) {
do (object, "onafterwear")
}
else if (HasString(object, "onafterwear")) {
msg (object.onafterwear)
}
}
else if (isLayerProblem = true) {
msg (DynamicTemplate("CannotWearOver",conflictedItem))
}
else {
msg (DynamicTemplate("CannotWearWith",conflictedItem))
}
}


BTW, thank you Pix :)