Weapons – Introduction

Okay, I need to make a NPC follow each player that touches it. It’s a classic ticking time bomb that creates a really large explosion when it’s finished. I figured the only way to do this cleanly is to make it a weapon.

Two things have been bothering me as I work out the details.

1: How do I update this bloody thing? I make changes to the NPC and they are not reflected in the weapon I already carry.
2: How do I delete a weapon from a player? Can’t seem to find the script command to do that. This thing needs to go away when it explodes.

You need to remove the weapon from the player. You then need to get the weapon back using the method you would normally.

You can remove a weapon from a player using rc, but also using script(use the destroy statement)
An example:

if (playerenters){
  toweapons onetimebomb;
}

if (weaponfired){
  putbomb 1,playerx+0.5+vecx(playerdir)*2,playery+1+vecy(playerdir)*2;
  setani grab,;
  destroy;
}

Also mashing the delete key in your inventory will delete stuff.

Thanks guys, I had no idea I could press delete in the Q menu. This allows me to quickly develop the weapon now that I’m picking up changes made to it.

The server creates a text file under the weapon name. What is that file’s purpose, and if I change that does it update anyone’s version of that weapon?

Also… I’m using showimg 1, tntpack.gif, playerx, playery; – this bomb follows the player around. I need it to count down, but message doesn’t seem to work for weapons for obvious reasons.
How do I get a message above my showimg?

I see that command may accept text, but I do not know the default values I need to use to get that to work.

followplayer;

Yeah, that definitely works online!

@Arial@[email protected] if I’m not mistaken. The rest is just like a normal showimg. You can change the r to b or i for bold or italic

There can only be one version of the weapon, let’s say a players get a weapon. You then update the weapon, and another player then receives it. The first player’s weapon will be updated.
The text file serves as a storage of the weapon, so that’s how we can have a triggerhack that can add weapons to players without the weapon definition having to be in the same level.
If you edit the file and then type /reloadweapons it’ll change the weapon’s behaviour as well, although this may be overwritten back to the normal script if the level script isn’t updated as well and someone gets the weapon in the level.

Okay, I’m real close on this one. Just one thing, this weapon is supposed to be automatic. You touch it, its yours… Imagine my surprise when this worked. Apparently the weapon “copy” of the NPC triggers the created flag when you pick it up.

[php]if (created && isweapon) {
this.countdown = 5;
timeout = 1;
}[/php]

I now have an automatic NPC following them around, that the player does not control. Victory!

Created being triggered when you get a weapon is would make sense. Good to know.