Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
NeptunesTyrant

ACS Newbie needs Help

Question

I'm trying to set up a "Call of Cthulu" type system where the player has a sort of secondary health type that when depleted kills the player but it's not working...


Enemies call this script when attacking with ACS_Execute:

Quote

 

script 1 (void)
{
    If(CheckInventory("Sanity") > 1)
    {
  Print(s:"You went Insane!");
    Thing_Damage(1,100); 
    }
 Else
 ACS_Terminate(1,33);
}


 

 

But when Sanity amount hits Zero nothing happens.

 

Anyone got any Ideas what I'm doing wrong?

Share this post


Link to post

4 answers to this question

Recommended Posts

  • 0

An alternative could be something like the following:

script 1 enter
{
 Thing_ChangeTID (0, 1000+PlayerNumber());
}

script 998 enter //The insanity script
{
 if (CheckInventory("Sanity")==0)
 {
  Thing_Damage2 (1000+PlayerNumber(), 400, "Insanity");
//Thing_Damage (1000+PlayerNumber(), 400, MOD_UNKNOWN); //If Thing_Damage2 doesn't work, try this line.
 }
 else
 {
  Delay (1);
  Restart; //Check again
 }
}

script 999 enter //The inverse of the above. Use one or the other, whichever works.
{
 if (CheckInventory("Sanity")!=0)
 {
  Delay (1);
  Restart; //Check again
 }
 else
 {
  Thing_Damage2 (1000+PlayerNumber(), 400, "Insanity");
 }
}

Simple if/else loop should accomplish the same objective (I've used it before, so I can attest that it should work), and just make the enemies' attacks do a specific damagetype and attach a new pain state to the player actor to take the "Sanity" item every time they suffer damage of this type, like here:

Actor Player : PlayerPawn
{
 Player.StartItem Sanity, 100
 DamageFactor Insanity, 1.0
 PainChance Insanity, 255
 States
 {
  Pain.Insanity:
  PLAY G 4 A_TakeInventory ("Sanity", 1)
  PLAY G 4 A_Pain
  goto Spawn
 }
}

This should result in the same end, and by compiling the ACS above and moving it into the wad internally, you wouldn't have to rewrite it once you got it working.

If this doesn't work, let me know.

Share this post


Link to post
  • 0

For one, you have the script set to terminate script 1 on MAP33.

And it looks like it's checking the monster's inventory for the "sanity" item, not the player's.

So, a possible solution could be this code:

script 1 enter
{
 Thing_ChangeTD (0, 1000+PlayerNumber());
}

script "Sanity Check" (void)
{
 If (CheckActorInventory (1000+PlayerNumber(), "Sanity")==0)
 {
  Print (s: "You went insane!");
  Thing_Damage2 (1000+PlayerNumber(), 400, "Insanity"); //This will negate any blue armor and/or extra health the player has
 }
 else
 {
  //Do nothing
 }
}

The first script will be executed by the players and give each a unique TID (Player 1 will be 1000, Player 2 1001, etc).

The script the monster calls will then check the inventory of the players (all of them) for "sanity" items. If they have zero, then the following block will execute for them, otherwise the else block will execute, which will do nothing because ACS scripts always terminate themselves at a closing brace (so ACS_Terminate or Terminate aren't needed).

Also, why the script didn't execute at zero was because you used the > "greater than" operator, not the < "less than" operator, which is understandably confusing, which is why I used the == "equivalent to" operator instead.

Hope it helps.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×