Troubling Scripting

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
alysiumX
Posts: 201
Joined: Sat Nov 20, 2004 1:13 pm

Troubling Scripting

Post by alysiumX »

I came across this problem while working on a project, What i want to do is when a monster gets kill, it give the player a certain amount of armor. I tried to do a action special of 80 on the monster leading to script that said giveinventory("armor", 5); and it wont work, any ideas?
User avatar
Enjay
 
 
Posts: 27279
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

Hmmm, I'm guessing that the monster is the activator of the script and is therefore the one getting the armour.

There may well be other/ better ways, but how about having a player activated script that simply checks for the presence of the crucial monster(s) and then when they are all dead gives the armour?
Richard213
Posts: 43
Joined: Sun Dec 05, 2004 1:35 pm

Post by Richard213 »

Hmmm. ThingCount(Type,TID); would be the way i'd do it.

Code: Select all

#include "zcommon.acs"

script 1 open
{
 if (Thingcount(0,213) == 0)   // if the actor with TID 213 dies
  {
   GiveInventory("Armor",5);   // give player 5% armor
  }
Delay(1);
restart;
}
User avatar
Enjay
 
 
Posts: 27279
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

I was thinking more like:

Code: Select all

script 1 (void)  
{
  while (Thingcount (0, 213) > 0)
  {
  delay (1);
  }
  GiveInventory("Armor",5);   	
}
Same nut, slightly different way to crack it. :)
Richard213
Posts: 43
Joined: Sun Dec 05, 2004 1:35 pm

Post by Richard213 »

Yeah that works too :P
User avatar
TheDarkArchon
Posts: 7656
Joined: Sat Aug 07, 2004 5:14 am
Location: Some cold place

Post by TheDarkArchon »

Actually, neither work: Use "ArmorBonus" as the item and then it'll work.
User avatar
alysiumX
Posts: 201
Joined: Sat Nov 20, 2004 1:13 pm

Post by alysiumX »

Thanks alot guys, its working now.
User avatar
Enjay
 
 
Posts: 27279
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

TheDarkArchon wrote:Use "ArmorBonus" as the item and then it'll work.
As I was typing my script, I had a feeling that had come up in a thread recently - ReX's healing pool thingy IIRC. Thanks for the correction.
Locked

Return to “Editing (Archive)”