Zombie Code Broken Again
jmnevil54
11 May 2017, 21:53Has The Pixie gotten some work done?
So anyways, I tried making a new functinon, a "SpawnGhoul" function. Lo and Behold, I ended up going to where I got the code from, and ended up messing the SpawnZombie function too.
I keep getting this error message that says it doesn't know what "CapFirst" is.
FunctionCallElement: Could find not function 'CapFirst(Object)'
Link: http://textadventures.co.uk/games/view/kmwqh7zyrkcrseuqrzuigg/zombie-2

DarkLizerd
12 May 2017, 03:28"CapFirst" takes the text "this is text." and changes it to read "This is text."
it capitalizes the first letter of the first word, sentence style...
You should be able to drop it without causing any problems...
(personally... the "help" documentation needs help!)
http://docs.textadventures.co.uk/quest/functions/string/capfirst.html
The Pixie
12 May 2017, 07:10Further to DarkLizerd's comment, it sounds like you are using CapFirst wrongly. The tutorial uses CapFirst with the monster's alias to ensure sentences start with a capital letter, and it should look like this (though it could be "obj" or "defender" instead of attack)
CapFirst(attacker.alias)
Somewhere, you have CapFirst without the bit afterwards.
That said, when I played it, I got a different error:
FunctionCallElement: Could find not function 'CapFirst(Object)'
That would indicate the alias is not set for the zombie, so you might want to check that in SpawnZombie. If you could paste the code from SpawnZombie we could take a look.
jmnevil54
15 May 2017, 00:42@The Pixie Yeah, that's the same error I got. I'll take a look at it.
jmnevil54
15 May 2017, 00:50Strange. The code says "CapFirst(obj.alias)" but the game says:
Error running script: Error compiling expression 'CapFirst(attacker.alias) + " attack " + target.alias + " and hit (" + damage + " hits)."': FunctionCallElement: Could find not function 'CapFirst(Object)'
DoAttack has 'CapFirst(attacker.alias) though.
Might as well take a look at the code.
Zombie:
if (HasInt(game, "crittercount")) {
game.crittercount = game.crittercount + 1
}
else {
game.crittercount = 1
}
create ("crittercount" + game.crittercount)
obj = GetObject("crittercount" + game.crittercount)
obj.parent = room
obj.displayverbs = Split("Look at;Attack;Shoot", ";")
obj.dead = false
obj.changedhitpoints => {
if (this.hitpoints < 1) {
msg ("It is dead!")
this.dead = true
player.exp = player.exp + 20
love
}
}
names = Split ("decipit;decomposing;shambling;disgusting;filthy;falling-apart", ";")
obj.alias = StringListItem (names, game.crittercount % ListCount(names)) + " zombie"
obj.listalias = CapFirst(obj.alias)
obj.look = ProcessText("A " + obj.alias + ", {random:covered in maggots:missing an arm:one eye hanging out}.")
obj.hitpoints = 8
obj.damage = 2
obj.attack = 0
obj.defence = 0
obj.armour = 0
DoAttack
if (firearm) {
damageatt = "firearmdamage"
attackatt = "firearmattack"
weapon.ammo = weapon.ammo - 1
}
else {
damageatt = "damage"
attackatt = "attack"
}
roll = GetRandomInt(1, 20) + GetInt(weapon, attackatt) - target.defence
if (HasInt(weapon, damageatt)) {
damage = GetInt(weapon, damageatt)
}
else {
damage = DiceRoll(GetString(weapon, damageatt))
}
damage = damage * (100 - target.armour) / 100
if (damage < 1) {
damage = 1
}
if (roll > 15) {
damage = damage * 3
msg (CapFirst(attacker.alias) + " attack " + target.alias + " and get a critical (" + damage + " hits)!")
target.hitpoints = target.hitpoints - damage
}
else if (roll > 4) {
msg (CapFirst(attacker.alias) + " attack " + target.alias + " and hit (" + damage + " hits).")
target.hitpoints = target.hitpoints - damage
}
else {
msg (CapFirst(attacker.alias) + " attack " + target.alias + " and miss...")
}
The Pixie
15 May 2017, 07:07The DoAttack function needs to have three parameters, "attacker", "weapon" and "target" (without quotes). I would guess "attacker" is either missing or mis-spelled.
jmnevil54
15 May 2017, 18:33Nah. I think the game just broke somehow. Is your's working too?
jmnevil54
16 May 2017, 22:19Nevermind, I got it. The parameters needed to be in a certain order, for some reason.

DarkLizerd
17 May 2017, 02:22Darn computer code!!! Always wanting things a certain way, in a certain order, and with the correct case!!!
:)
jmnevil54
17 May 2017, 02:33:)