Teleporting a player and a zombie Stallin

I just need help with my teleportation method. I can't get it to work.

This is the function that both teleports Spawns Zombie Stallin and teleports player.

Tele 1
MoveObject (player, Battle Fucking Room)
if (HasInt(game, "crittercount")) {
  game.crittercount = game.crittercount + 1
}
else {
  game.crittercount = 1
}
create ("critter" + game.crittercount)
obj = GetObject("critter" + game.crittercount)
firsttime {
  obj.parent = player.parent
}
obj.displayverbs = Split("Look at;Attack;Shoot", ";")
obj.dead = false
obj.changedhitpoints => {
  if (this.hitpoints < 1) {
    this.dead = true
    msg ("It is dead!")
    player.exp = player.exp + 20
    player.gold = player.gold + 20
    love
    this.displayverbs = Split("Look at;Search", ";")
    Tele 2
    this.parent = player.parent
  }
}
names = Split("decrepit;decomposing;shambling;disgusting;filthy;falling-apart", ";")
obj.alias = StringListItem(names, game.crittercount % ListCount(names)) + " Stallin"
obj.listalias = CapFirst(obj.alias)
obj.look = ProcessText("A " + obj.alias + ", {random:covered in maggots:missing an arm:one eye hanging out}.")
obj.hitpoints = 30
obj.damage = 2
obj.attack = 1
obj.defence = 0
obj.armour = 0
obj.selectweapon => {
  if (RandomChance(10)) {
    if (this.weapon = vomitreadying) {
      this.weapon = Spade2
    }
  }
  else {
    this.weapon = GetObject(PickOneString("vomitreadying;talonattack;kickattack;Spade2"))
  }
}
obj.searchscript => {
  if (RandomChance(1)) {
    player.potion = player.potion + 1
  }
  else if (RandomChance(2)) {
    if (game.hard = true) {
      player.ammo = player.ammo + 7
    }
  }
  else if (RandomChance(1)) {
    player.hyper_potion = player.hyper_potion + 1
  }
}
obj.critdesc = "A well-placed blow by #attacker# sends you reeling (#hits# hits)."
obj.attackdesc = "#Attacker# has hit you (#hits# hits)."
obj.missdesc = "#Attacker# misses you."\

These are my 2, teleportation codes.
Tele 1

player.current_room = player.parent
player.old_room = player.current_room

Tele 2

player.parent = player.old_room

And this is my game. I made it in a rage. Please be 18 or older, I put too many cuss words in this.
http://textadventures.co.uk/games/view/fo9bej7z0kqiy_wxal2tcq/fing-game


K.V.

player.current_room = player.parent

This sets player.current_room to the current location.

player.old_room = player.current_room

This sets player.old_room to the current location.

player.parent = player.old_room

This sets the player's location to the current location, so nothing happens. The player is already in the current location.


When I try the game, I just get an error that there's an unexpected \ … the last character in the code you pasted here.


Aside from that, the script appears to work exactly as intended. Tele 1 stores your current location; then you get teleported to the battle room; beat the monster and Tele 2 teleports you back to where you were.

When you enter other rooms with a call to SpawnZombie, it moves you to the battle room but you can't get back because you don't have a zombie to kill. A second zombie is created but isn't moved to the battle room, because:

firsttime {
  obj.parent = player.parent
}

*smacks head
That solves that error, then...

I'm still getting a....

Error running script: Error compiling expression 'Replace(s, "#Attacker#", CapFirst(GetDisplayAlias(attacker)))': FunctionCallElement: Could find not function 'Replace(Object; String; String)'

Yeah, the First time script is toying with me....
I got this again.


You are in a That 1.
You can go north or south.

You are in a Battle Fucking Room.
You did something.

It's supposed to spawn a zombie here.


So if I remove the first time scripts, what do I replace it with?

(Weirdly enough, this worked in my old game pretty much, only side effect was, the monsters' dead bodies kept following me everyone. Hence my attempt at the first script......... C'est la vie....)


I think you want the zombie to move to the battle room every time they spawn, not just the first time you enter. So obj.parent = player.parent or obj.parent = Battle Fucking Room without the firsttime.

Error running script: Error compiling expression 'Replace(s, "#Attacker#", CapFirst(GetDisplayAlias(attacker)))': FunctionCallElement: Could find not function 'Replace(Object; String; String)'

That's because you're calling AttackReport (weapon.missdesc, attacker, target, 0) (from DoAttack) when the 'weapon' variable is the zombie itself because it doesn't have a weapon.
The zombie doesn't have an attribute 'missdesc'; so it complains it can't do Replace() on null (which is technically an Object)

The zombie doesn't have a missdesc because, as previously noted,

obj.missdesc = "#Attacker# misses you."\

has an unnecessary \ at the end of the line, which causes it to fail.


No, I got that.

Tele 1
MoveObject (player, Battle Fucking Room)
if (HasInt(game, "crittercount")) {
  game.crittercount = game.crittercount + 1
}
else {
  game.crittercount = 1
}
create ("critter" + game.crittercount)
obj = GetObject("critter" + game.crittercount)
firsttime {
  obj.parent = player.parent
}
obj.displayverbs = Split("Look at;Attack;Shoot", ";")
obj.dead = false
obj.changedhitpoints => {
  if (this.hitpoints < 1) {
    this.dead = true
    msg ("It is dead!")
    player.exp = player.exp + 20
    player.gold = player.gold + 20
    love
    this.displayverbs = Split("Look at;Search", ";")
    Tele 2
    this.parent = player.parent
  }
}
names = Split("decrepit;decomposing;shambling;disgusting;filthy;falling-apart", ";")
obj.alias = StringListItem(names, game.crittercount % ListCount(names)) + " Stallin"
obj.listalias = CapFirst(obj.alias)
obj.look = ProcessText("A " + obj.alias + ", {random:covered in maggots:missing an arm:one eye hanging out}.")
obj.hitpoints = 30
obj.damage = 2
obj.attack = 1
obj.defence = 0
obj.armour = 0
obj.selectweapon => {
  if (RandomChance(10)) {
    if (this.weapon = vomitreadying) {
      this.weapon = Spade2
    }
  }
  else {
    this.weapon = GetObject(PickOneString("vomitreadying;talonattack;kickattack;Spade2"))
  }
}
obj.searchscript => {
  if (RandomChance(1)) {
    player.potion = player.potion + 1
  }
  else if (RandomChance(2)) {
    if (game.hard = true) {
      player.ammo = player.ammo + 7
    }
  }
  else if (RandomChance(1)) {
    player.hyper_potion = player.hyper_potion + 1
  }
}
obj.critdesc = "A well-placed blow by #attacker# sends you reeling (#hits# hits)."
obj.attackdesc = "#Attacker# has hit you (#hits# hits)."
obj.missdesc = "#Attacker# misses you."

The stupid thing is, I probably have the answer somewhere in my e-mail, since I already asked this.
But I got The Pixie on it again........ I'll just... go search my email.

Will see if the other thing works too.


...It worked.
Thanks.


K.V.

Sorry, I only read the bit at the end:

These are my 2, teleportation codes.

Tele 1

player.current_room = player.parent
player.old_room = player.current_room

Tele 2

player.parent = player.old_room

That's what I based my response on.

(One day, I'll learn to READ things, not just SCAN them!)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums