Trying to turn Pixie's Spawn Zombie into a Monster Object

I'm trying to make a creature using Pixie's Zombie Apocalypse rule-set, but changed to a drone that is an object rather than a Spawn Function. I'm clearly missing something as I keep getting an error:

The drone doesn't try to DoAttack on it's own and when I try to attack it I get the following:

Error running script: Error compiling expression 'Replace(s, "#Attacker#", CapFirst(GetDisplayAlias(attacker)))': FunctionCallElement: Could find not function 'Replace(Object, String, String)'
Error running script: Error compiling expression 'if (this.hitpoints < 1)': SyntaxError: Unexpected token ")"; expected one of ","Line: 1, Column: 31

      <inherit name="editor_object" />
      <inroomdescription>This drone was clearly well-loved.  There's not a spot of rust on it.</inroomdescription>
      <look>This drone hovers a few feet above the ground, guns mounted beneath the chassis.  This looks like a wastelander bodge job.  Definitely post-incident, but likely without the killerbot programming.  Otherwise, why keep it here at all?</look>
      <displayverbs type="stringlist">
        <value>Look at</value>
      <feature_startscript />
      <attr name="_initialise_" type="script">
      <hitpoints type="int">20</hitpoints>
      <damage type="int">3</damage>
      <attack type="int">2</attack>
      <defence type="int">2</defence>
      <armour type="int">2</armour>
      <critdesc>"A well-placed blow by #attacker# sends you reeling (#hits# hits)."</critdesc>
      <attackdesc>"#Attacker# has hit you (#hits# hits)."</attackdesc>
      <missdesc>"#Attacker# misses you."</missdesc>
      <dead type="boolean">false</dead>
      <selectweapon type="script">
        names = Split("droneweapons;droneweapons;droneweapons", ";")
        name = StringListItem(names, this.weaponcount % ListCount(names))
        this.weapon = GetObject(name)
        this.weaponcount = this.weaponcount + 1
      <changedhitpoints type="script"><![CDATA[
        if (if (this.hitpoints < 1)) {
          msg ("\"It collapses to the ground in a cloud of sparks!\"")
          this.dead = true
          this.displayverbs = Split("Look at;Loot", ";")
      <searchscript type="script">
        MoveObjectHere (drone bullet pack 1)
        msg ("You crack open the casing and find 22 bullets that you can use in your gun.  Unfortunately the drone's AI chip is fried -- a bullet's lodged inside it.  That's no use to you now.")

Well, the first error is in the line Replace(s, "#Attacker#", CapFirst(GetDisplayAlias(attacker))).

This line isn't in the code you pasted, but appears to be in the function AttackReport.
So, check that function. and where it's called. Unless you changed something, it looks like it's only called from DoAttack.

That error message implies that either weapon.critdesc, weapon.attackdesc, or weapon.missdesc is an object rather than a string. The most common cause for a variable being an object when it should be a string is that an attribute isn't defined - then its value is null, which shows up as an object in error messages.

If it happens when you try to attack the drone, it's likely that the player's weapon is missing one of those attributes. Maybe a typo in the attribute name?

The second error is the line:
if (if (this.hitpoints < 1)) {
which should be
if (this.hitpoints < 1) {

I just realised I hadn't equipped the gun on the player when I tried to attack, doing that I can now tear the thing apart. It would be good to have some kind of base attack one can use even if one doesn't have a weapon. I fixed up that typo and used my weapon and I managed to knock it down.

However the drone won't hit me back...

It would be good to have some kind of base attack one can use even if one doesn't have a weapon.

It looks to me like the player's attackdesc, critdesc, and missdec attributes are used if they don't have a weapon.

However the drone won't hit me back...

Is the turnscript enabled?

It works just fine with the SpawnZombie script. For some reason the Drone Object isn't talking to the turnscript the same way that the SpawnZombie script does. I tried to massage all the SpawnZombie stuff into the object.... Took another look and realised this bit might not be working. I tried putting this in the drone's Initialisation Script but that doesn't seem to be helping. It just makes the random msg appear in whatever room I'm in when I start up the game.

  msg ("\"random:patrols the room;hovers silently;slowly rotates.\"")
else if ((ListContains(ScopeReachable(), player))) {
  msg ("\"DoAttack\"")

Can you share the script you've got?
There's not much we can figure out without actually seeing the code that's misbehaving.

And ScopeReachable() will never contain the player.

Log in to post a reply.