"How do I ZScript?"

Discuss all aspects of editing for ZDoom.
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Re: "How do I ZScript?"

Postby sonic_HD87 » Thu Feb 16, 2017 5:43 pm

There is an equivalent of GetPlayerInput but on ZScript?
User avatar
sonic_HD87
Intel GM45 Master Race
 
Joined: 23 Mar 2013
Location: Venezuela

Re: "How do I ZScript?"

Postby Gutawer » Thu Feb 16, 2017 6:04 pm

User avatar
Gutawer
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: "How do I ZScript?"

Postby Gutawer » Thu Feb 16, 2017 8:28 pm

Is there any way to do a simple tracer in ZScript? I.e. take a vector, send out a ray from that vector at a pitch & angle and get the Vector3 of wherever it collides with something (in 1 tick), be it wall or solid actor?
User avatar
Gutawer
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: "How do I ZScript?"

Postby Nash » Thu Feb 16, 2017 10:24 pm

The best you'll get for now is AimLineAttack and LineAttack, and you can only use it to retrieve actors. You can't retrieve lines or sectors because the generic TraceResult isn't exported.

The difference between the two is that LineAttack also takes in pitch, and you can specify puffs to spawn and the damage.

Here's a test Demon that will run around looking for Z_TeleportMarkers to "use", by firing a trace in front of it every tic. When the trace hits a Z_TeleportMarker, it will "use" the thing.

Code: Select allExpand view

class Z_Demon 
: Demon replaces Demon
{
    void UseTeleportMarkers(void)
    {
        double useDist = 64.f,
                vDist = 35.f;

        // find things to use
        FTranslatedLineTarget t;
        AimLineAttack(Self.Angle, useDist, t, vDist, ALF_FORCENOSMART | ALF_CHECKCONVERSATION | ALF_PORTALRESTRICT);
        bool usable = (t.LineTarget != null && t.LineTarget is "Z_TeleportMarker");

        if (usable)
        {
            int tmID = t.LineTarget.TID,
            tmDest = t.LineTarget.args[0];
            vector3 destPos;

            if (tmDest != 0)
            {
                // find the actor with the matching TID
                ActorIterator it = ActorIterator.Create(tmDest);
                Actor a = it.Next ();
                if (a)
                {
                    destPos = a.Pos;

                    // some adjustment needed
                    // to do: handle blocked/congested destination more gracefully
                    double posAdjust = 40.f;
                    destPos = (destPos.+ Cos(a.Angle) * posAdjust, destPos.+ Sin(a.Angle) * posAdjust, destPos.Z);
                }

                // to do: add fade out/fade in
                Self.Angle = a.Angle;
                Self.Pitch = 0;
                Self.SetXYZ(destPos);
            }
        }
    }

    override void Tick(void)
    {
        UseTeleportMarkers();
        Super.Tick();
    }
}


In your case, if you want to retrieve the position, you'd use

Code: Select allExpand view

Vector3 myPos 
= t.LineTarget.Pos;
 
User avatar
Nash
Nash Muhandes [Audio Engineer | Game Designer | Scripting]
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Postby Graf Zahl » Fri Feb 17, 2017 5:15 am

Trace should be exported but its implementation requires some C-isms to fully support its features, and that doesn't exist.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: "How do I ZScript?"

Postby Nash » Fri Feb 17, 2017 7:07 am

Code: Select allExpand view

struct FCharacter
{
    
String characterClass// used to be the DECORATE class
    
int refID;

    
// the name that's shown in dialogs
    
String firstNamelastNamenickName;

    
// default base container to attach to this character
    
String defaultContainerClass;

    
// holds refID of this character's container
    
int containerID;

    
// NPC, zombie or player?
    
int characterType;

    
// only 1 copy of this character allowed, ever. subsequent spawns will fail and print a warning
    
bool isUnique;

    
// protected = cannot be killed by anything except players
    // essential = cannot be killed, ever
    
int deathProtection;

    
int sex;
    
int ethnicity;

    
// only for players
    // hair and face stuff only appear in paperdoll screen
    
int hairTypefacialHairType,
        
hairLengthfacialHairLength;
    
int faceType;

    
// high muscle value adds strength bonuses
    // eat too much will cause bloating which increases fat value (makes movement slower, stamina runs out faster)
    // question: should these be implemented as (de)buffs instead of player properties?
    
int musclefat;

    
// which dialog set does this NPC have
    // (conversation ID)
    
int dialogSet;

    
// which schedule/AI script to follow
    // (for idle behavior or sleep/travel schedules.
    // can also be given by dialogs to perform scripted scenes)
    
int AIPackage;

    
// which user script to run when this character dies
    
String deathScript;

    
// stats
        // attributes
    
int level,
        
healthmaxHealth,
        
staminamaxStamina,
        
hungermaxHunger,
        
thirstmaxThirst,
        
energymaxEnergy,
        
strength,
        
mind,
        
agility,
        
vitality,
        
charisma,
        
luck,
        
// skills
        
blade,
        
blunt,
        
bow,
        
unarmed,
        
guns,
        
electrical,
        
carpentry,
        
cooking,
        
farming,
        
sneak,
        
perception,
        
hunting,
        
medicine,
        
athletics,
        
persuasion;

    
// head has been destroyed, this character can no longer turn into a zombie or reanimate
    
bool isReallyDead;

    
// all zombies have this enabled
    
bool isUndead;

    
// limb damages are in percent
    
int headHealth,
        
torsoHealth,
        
armLHealth,
        
armRHealth,
        
legLHealth,
        
legRHealth;

    
// a list of the refIDs of this character's active effects ((de)buffs)
    
int activeEffect[100];

    
// currently equipped stuff
    // holds refIDs of items to be equipped
    
int curWeapon,
        
curLight,
        
// clothes
        
curGlasses,
        
curUnderShirt,
        
curShirt,
        
curGloves,
        
curUnderPants,
        
curPants,
        
curShoes,
        
// armor
        
curHelmet,
        
curBodyArmor,
        
curArmLAmor,
        
curArmRArmor,
        
curLegLArmor,
        
curLegRArmor;
}

class Z_Actor : Actor
{
    Default
    
{
    }

    FCharacter stat;

    static int GetHunger (Actor self)
    {
        return self.stat.hunger;
    }

}
 


It says "unknown identifier stat". How do I retrieve the hunger member from the stat struct?
Last edited by Nash on Fri Feb 17, 2017 7:23 am, edited 1 time in total.
User avatar
Nash
Nash Muhandes [Audio Engineer | Game Designer | Scripting]
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Postby Graf Zahl » Fri Feb 17, 2017 7:22 am

Where's the FCharacter struct?
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: "How do I ZScript?"

Postby Nash » Fri Feb 17, 2017 7:23 am

Oh I didn't post it because I thought it was too long for the forum. But it's there in my ZScript files. It still doesn't work.
User avatar
Nash
Nash Muhandes [Audio Engineer | Game Designer | Scripting]
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Postby Graf Zahl » Fri Feb 17, 2017 7:33 am

It cannot find 'stat' because you pass in a pointer to 'Actor', ot 'Z_Actor'.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: "How do I ZScript?"

Postby Nash » Fri Feb 17, 2017 7:36 am

D'oh! Works perfectly now. Thanks! :D
User avatar
Nash
Nash Muhandes [Audio Engineer | Game Designer | Scripting]
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Postby Nash » Fri Feb 17, 2017 8:25 am

Question @ ZZYZX:

Old way:

Code: Select allExpand view

Bind Shift
=pukename Script_ActivateSprint

// ACS
script "Script_ActivateSprint" (void) net
{
    // activate sprint mode
}


ZScript events way how? Help me please Event God. :D
User avatar
Nash
Nash Muhandes [Audio Engineer | Game Designer | Scripting]
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Postby Expect No Mercy » Fri Feb 17, 2017 8:41 am

Xaser wrote:Now, there is one thing you can do currently: make the sprites themselves translucent (i.e. PNG with an alpha channel). These will appear translucent in the GL renderer, and also the Software renderer if using the D3D layer (only available on Windows, though, and users can turn it off if they so desire). Best you can get, but it's better than nothing.


Have tested this now, and it works. But brightmaps didn't work on these. :(
User avatar
Expect No Mercy
 
Joined: 18 Mar 2012

Re: "How do I ZScript?"

Postby Gutawer » Fri Feb 17, 2017 9:08 am

Nash wrote:The best you'll get for now is AimLineAttack and LineAttack, and you can only use it to retrieve actors. You can't retrieve lines or sectors because the generic TraceResult isn't exported.

Ah, well that's a shame then, to do what I need to do I'd need to get a set of coordinates of where the tracer hit regardless if it hit an actor or a sector/line, so I'll have to find another way.
@Graf - Can I ever expect a tracer function to be exported, or will those C-isms always hold it back?
User avatar
Gutawer
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: "How do I ZScript?"

Postby Nash » Fri Feb 17, 2017 10:05 am

You can use LineAttack to spawn a puff and retrieve the puff's Vector3 position.
User avatar
Nash
Nash Muhandes [Audio Engineer | Game Designer | Scripting]
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Postby sonic_HD87 » Fri Feb 17, 2017 11:24 am

Gutawer wrote:Yes, GetPlayerInput. :P
https://zdoom.org/wiki/GetPlayerInput_(DECORATE)


It doesn't matter if it says "development version only"?
User avatar
sonic_HD87
Intel GM45 Master Race
 
Joined: 23 Mar 2013
Location: Venezuela

PreviousNext

Return to Editing

Who is online

Users browsing this forum: Bing [Bot], CloudyJason22, CurtisNHL1, RedRoyalGuard, Yandex [Bot] and 4 guests