npc question
cyberlinxz
13 Nov 2016, 22:04I am using pixie clothing lib and I an wanting my npc to be able to wear clothing I know that it should be easy to do but I just can seem to come up with it. Can some one help me plz
XanMag
14 Nov 2016, 03:02I am not familiar with Pixie's clothing library, but I am assuming in the look at description you will have flags set on the NPC.
If NPC has flag outfit1, then print message "Hey. NPC looks to be wearing a tuxedo."
Else If, NPC has flag outfit2, then print message "Look there. The NPC is wearing a bathing suit."
Else If, etc, etc, etc, etc
Else print message "OMG! The NPC is totally naked!"
You would of course need to set flag outfit1 on NPC for whatever event you want to trigger the flag and deactivate any flag previously set.
'Sell tuxedo to NPC'. Print message, "The NPC loves the tuxedo and throw it on immediately." Set flag NPC outfit1.
'Give bathing suit to NPC'. Print message, "The NPC throws on the bathing suit and looks ready for a swim." Set flag NPC outfit2. Unset flag NPC outfit1.
I urge you, however, to make sure that your grammar is done properly in a text adventure game. It is TEXT adventure after all. I'll assume the forum post is just very informal. Just a bit of advice - nothing will ruin a text adventure game more than grammar errors. Take no offense please. Just trying to help. =)
EDIT: You may want to wait on Pixie (or another) that is familiar with the library. There may be a different way to handle it based on how the library is set up.
cyberlinxz
14 Nov 2016, 03:31I will try that and I thank you for the advice I am bad at spelling but do you a spell checker on the program to check for spelling and grammer .
The Pixie
14 Nov 2016, 08:03Did you look at the tutorial:
https://github.com/ThePix/quest/wiki/Clothing-Library
There is no easy way to spell check, but one approach is to open the game with a text editor with spell checker. I use Notepad++ (the spell checker is a plug-in, "DSpellCheck"). This means you will be looking through the code, so a minimal familiarity with XML (or HTML) would be useful so you are spell checking text and not the XML tags.
cyberlinxz
14 Nov 2016, 17:09I did look at the link before asking but did not understand it. I am new to java and trying to use it but on the link I did not know where to place the if statements that I want. I am wanting to have it to where if the npc is wearing it, it can not be taken but when it is removed by the npc then it is able to be seen that they are not wearing clothes and it can be taken. Also have a scene that the npc puts up a fight for a object if it is taken while they have it with a random chance of success or failure and with a chance of it being broken.
As for the spellchecking I write the desc. and the story plot on open office to be able to spellcheck I will try and see how it works in notepad ++.
If you could help me with this pixie it would be nice I am going to try to see if XanMag way will work for what I need but if you know a easier way that would be nice
Thank you both for your help
The Pixie
15 Nov 2016, 08:23Thinking about it, the bit on NPCs does not explain much - but that is because I cannot guess what people will want to do with NPCs.
I guess the best way to do that would be to override the DoTake
function. If you look in that you should see these lines towards the top:
else if (not ListContains(ScopeReachable(), object)) {
msg (prefix + DynamicTemplate("ObjectNotOpen", GetBlockingObject(object)))
}
Say you have an NPC called Mary, add three lines after them (and you add a further three lines for each NPC):
else if (not ListContains(ScopeReachable(), object)) {
msg (prefix + DynamicTemplate("ObjectNotOpen", GetBlockingObject(object)))
}
else if (object.worn and object.parent = Mary) {
msg (prefix + "Mary is wearing " + object.article + "." )
}
If you have a lot of NPCs, it would be better to make it more general, but this will be easier and should work fine.
It is not Java, by the way, though it does look similar in many ways; the language is unique to Quest.
Guide to spell-checking:
https://github.com/ThePix/quest/wiki/Spell-Checking
cyberlinxz
15 Nov 2016, 12:20Thank you pixie that is what I needed and thank you
cyberlinxz
15 Nov 2016, 17:33I have another question if some one can answer I am placing it here so I do not place to many forms out
Here is the code I have:
if (OutOfAmmo()) {
do (this, "outofammo")
}
else if (this.dead) {
// s = GetDisplayAlias(this)
// msg("The " + Mid(s, 1, LengthOf(s) - 7) + " is already dead.")
msg ("The " + GetDisplayAlias(this) + " is already dead.")
}
else {
SneakUpdate (5)
do (this, "settoattack")
attackroll = GetRandomInt (1, 20) + GetAttack(this)
if (this.noncorporeal and GetElement(game.pov.equipped) = null) {
if (game.pov.equipped.nonweapon) {
msg ("You attack the " + GetDisplayAlias(this) + ", and pass straight through it!")
}
else {
msg ("You swing your " + GetDisplayAlias(game.pov.equipped) + " and it goes straight through the " + GetDisplayAlias(this) + "!")
}
}
else if (attackroll > 10) {
damage = GetDamage (game.pov.equipped, game.pov.strength / 2 + this.temp_damage + game.pov.damagebonus, this)
this.hitpoints = this.hitpoints - damage
if (this.hitpoints > 0) {
if (game.pov.equipped.nonweapon) {
msg ("You attack and hit, doing " + damage + " points of damage (" + this.hitpoints + " hits left). " + this.hurtbyweapon)
}
else {
msg (this.temp_desc + " " + GetDisplayAlias(game.pov.equipped) + " and hit, doing " + damage + " points of damage (" + this.hitpoints + " hits left). " + this.hurtbyweapon)
}
if (HasScript(this, "onweaponhit")) {
do (this, "onweaponhit")
}
if (HasObject(game.pov.equipped, "venom")) {
if (this.poisonimmunity) {
if (HasString(this, "poisonimmunitymsg")) {
msg (this.poisonimmunitymsg)
}
else {
msg ("The " + GetDisplayAlias(this) + " is immune to your blade venom.")
}
}
else {
game.pov.target = this
do (game.pov.equipped.venom, "effect")
}
game.pov.equipped.venom = null
}
}
else {
if (game.pov.equipped.nonweapon) {
msg ("You attack and hit, doing " + damage + " points of damage. " + this.death)
}
else {
msg (this.temp_desc + " " + GetDisplayAlias(game.pov.equipped) + " and hit, doing " + damage + " points of damage. " + this.death)
}
do (this, "makedead")
}
}
else {
if (game.pov.equipped.nonweapon) {
msg ("You attack and miss.")
}
else {
msg ("You swing your " + GetDisplayAlias(game.pov.equipped) + " and miss.")
}
}
if (HasObject(game.pov, "secondary_attack")) {
do (this, "secondaryattack")
}
SetTimeout (5) {
if (goblin.dead = True) {
}
else {
do (goblin, "doattack")
}
}
}
What I am trying to do is make it that once you attack the attack kept going till (player is dead, monster is dead, or player leaves room)
it is under the doattck attributes from pixie's combat lib
I got it to work for the player but the npc is not fighting back and that is where I am stuck
The Pixie
16 Nov 2016, 14:53If I understand right...
That script will fire once each time the player makes an attack. When it does so, it will start a timer which will cause the goblin to attack 5 seconds later - but only after the player has made an attack.
What you need to do is set up a timer object (right click in the left pane), and have it fire every five seconds. It can then check all the objects in the current room and see if any should be attacking, and if so, do the attack then.