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

Conditions hate me

Question

I cannot, for all that is sacred, understand why IF conditions and whatnot hate me so much.

 

1) This is a script I made to mod Brutal Doom's flashlight so it should drain energy cells while it's on:

Spoiler

#library "FLASHLIGHTDRAIN"
#include "zcommon.acs"

script "FLASHLIGHTBATTERY" ENTER
{
    if (CheckInventory("FlashlightOn") && CheckInventory("Ammocell") >= 1)
    {
        Delay(35*7);
        Takeinventory("Ammocell",1);
    }
    
    else
    {
        Takeinventory("FlashlightOn",1);
    }
delay(1);
}

"flashlighton" is a dummy item given to player's inventory when he switches the flashlight on (duh). So theoretically, the script should take cells with pauses of 7 seconds when the player both has the flashlighton item and at least one "ammocell" which is the brutal doom's counterpart of "cell". ELSE, the  flashlight should stay off. Except nothing is working.

 

2) This is one of my first scripts, it takes a random selection of ammo and weapons when entering a map. I wanted it to do so only for a specific playerclass:

Spoiler

#library "WEAPONTAKERACS"
#include "zcommon.acs"

script "WEAPONTAKER" ENTER
 {
   str class = "WeaponTaker";
 
   if (Checkclass("MiseryDoomer"))
   {
     delay(1);    
     int x = GetActorX(0);
     int y = GetActorY(0);
     int z = GetActorZ(0);
     spawn(class,x,y,z,0,0);
     delay(1);
   }
 }

Instead, it works perfectly... but for every playerclass. Condition ignored. Why?

 

3) I'm trying to create a script activated by some monster's melee attacks. These should give a bleeding effect IF the player is not wearing adequate armor, with a damage absorb of at least 40%

Spoiler

Script "RUPTURE" (void)       //Open wound inflicted by monsters
{
    int armorsave = GetArmorInfo(ARMORINFO_SAVEPERCENT);
    int i;
    
    If (armorsave < 39.0)
    {
        for (i=0;i<10;i++)
        {
        SetActivatorToTarget(0);
        Thing_Damage2(0,1,"poisonDAMAGE");
        SetHudSize(640, 480, true);
        setfont("SCRATCH");
        HudMessage(s:"A"; HUDMSG_FADEINOUT, 202, CR_UNTRANSLATED, 320.0, 240.0,10.0);
        delay(35*3);
        }
    }
}

I created a custominventory item to give the status to me when used. And, you guessed it... The bleeding effect is given to me, no matter what kind of armor I'm wearing.

 

ACS, WHY WON'T YOU LOVE ME?

 

Edited by Grey_Wolf

Share this post


Link to post

7 answers to this question

Recommended Posts

  • 1

1. your script works exactly one time, at level enter. then it dies. you forgot to surround your code with `while (1) {}`.

 

2. `CheckClass()` checks if class is valid,  not activator class. as your mod prolly has `MiseryDoomer` class, it is always valid.

 

3. activator is monster. it has no armor. you need to check if target is player, then switch to target, and only then you can check armor. also, there is no need to switch to target inside a loop, it is enough to do it once before loop (and you have to do it ealier anyway, as i wrote).

Share this post


Link to post
  • 0

...Sigh.

 

Case 1 is solved, thank you kindly.

 

For the second issue I think I can come up with something myself now that you clarified that point.

 

As for the third case, I said in the last post that for now and for testing purposes, I used a dummy inventory item to auto-inflict the status upon use, so there's no monster involved. Also, I will then need to make the script run only if the monster's melee attack actually HITS the player. And I have no clue on how I could pull that off.

Share this post


Link to post
  • 0

sorry, i misread your 3rd point. still, activator is prolly wrong there -- it is either world, or inventory item, i think.

Share this post


Link to post
  • 0

I'm trying to get it to work from the monster's attack. Still no luck.

This is what I tried:

 

DECORATE:

Spoiler

ACTOR ImpAttack: BaronBall   //IMP CLAW ATTACK
{
    Radius 10
    Height 18
    DamageType Rip
    Projectile
    Radius 4
    +RANDOMIZE
    Damage (random(20,20))
    +FORCEXYBILLBOARD
    +THRUGHOST
    +BLOODSPLATTER
    +HITTRACER
    RenderStyle Add
    Alpha 0.6
    HitObituary "$OB_IMPHIT"
    Obituary "$OB_IMPHIT"
    +DONTHURTSPECIES

    SeeSound "None"
    DeathSound "none"
    Decal "none"
    Speed 20
    States
    {
    Spawn:
        TNT1 A 4 BRIGHT
        Stop
    Death:
        TNT1 A 0 A_PlaySound("imp/melee")
        TNT1 A 0 ACS_NAMEDEXECUTE("RUPTURE")
        TNT1 A 0 BRIGHT
        Stop
    }
}

ACS SCRIPT:

Spoiler

Script "RUPTURE" (void)       //Open wound inflicted by monsters
{
    int armorsave = GetArmorInfo(ARMORINFO_SAVEPERCENT);
    int i;
    
    If (armorsave < 39.0)
    {
        SetActivator(0, AAPTR_TRACER);
        for (i=0;i<10;i++)
        {
        Thing_Damage2(0,2,"poisondamage");
        SetHudSize(640, 480, true);
        setfont("SCRATCH");
        HudMessage(s:"A"; HUDMSG_FADEINOUT, 202, CR_UNTRANSLATED, 100.0, 240.0,10.0);
        delay(35*3);
        }
    }
}

 

I thought that putting the HITTRACER flag on the attack and then setting the activator of the script to the projectile's tracer would do the trick. I guess I was wrong.

The Hudmessage shows though, probably because that command can only be executed on the player. Infact, the picture shows even when the imp is attacking something else. But that'll be a problem for another time.

Share this post


Link to post
  • 0

as i said, only player has armor. in fact, it is UB to call `GetArmorInfo()` on non-player actor. you have to change activator first. then, you have to check if activator (new one) is player. and only if it is, you can check armor and do other things.

 

as for hud messages -- activator is irrelevant for them: there is only one HUD in game. ;-)

Share this post


Link to post
  • 0
Quote

as i said, only player has armor. in fact, it is UB to call `GetArmorInfo()` on non-player actor. you have to change activator first. then, you have to check if activator (new one) is player. and only if it is, you can check armor and do other things.

AAARGH, I'm such an idiot! Sorry about that.

 

By the way, I tried other solutions but with no results. Since the topic quite drifted away from its original purpose and I'll feel guilt if I keep asking you for help, I think I'll just keep trying or move to another forum for this time, so you can take a break from my incompetence XD

Share this post


Link to post
  • 0

it is still "ontopic" for me: after all, it is all connected to your initial questions. doom scripting is complicated, and even sometimes quite illogical, so it is hard to draw a line between ontopic/offtopic.

 

tbh, i am maintaining a sourceport, yet i still confused by various things and their interop almost on a daily baisis. ;-)

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
×