Simple Zscript issue <solved>

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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.

Simple Zscript issue <solved>

Postby deathzero021 » Wed Nov 13, 2019 4:16 pm

I can't get this to launch at all. I get an error saying "unexpected end of file" at line 15.

Code: Select allExpand view
extend class Actor
{
void A_CustomMelee2 (int MeleeDamage, Sound MeleeSound)
   {
   let targ = target;
   if (targ == NULL) return;

   if (MeleeDamage>0 && CheckMeleeRange ())
   {
      int damage = MeleeDamage;
      if (MeleeSound) A_PlaySound (MeleeSound, CHAN_WEAPON);
      int newdam = targ.DamageMobj (self, self, damage, 'Normal');
      targ.TraceBleed (newdam > 0 ? newdam : damage, self);
   }
}


I really don't know much about zscript, I'm just trying to add a variant of the melee attack.

P.S. where can I get information on "checkmeleerange"?

Edit: simple bracket missing. And can't extend Actor. Create new class and define function there.
Last edited by deathzero021 on Wed Nov 13, 2019 5:21 pm, edited 1 time in total.
User avatar
deathzero021
 
Joined: 24 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Simple Zscript issue

Postby Tartlman » Wed Nov 13, 2019 4:26 pm

You're missing a bracket. That's why you get that error.

Also, i don't think you're allowed to extend actor, unfortunately.
User avatar
Tartlman
shitposting with zscript
 
Joined: 11 Oct 2018
Location: meme hell
Discord: bogus#2947

Re: Simple Zscript issue

Postby deathzero021 » Wed Nov 13, 2019 5:09 pm

Haha thanks. I knew it must've been something dumb. I'm not used to coding in an editor that doesn't perform basic syntax checks like that and my indentations were off my usual style. And if we can't extend it, than how do we add any functions? Do we have to add it directly to a class we define?

Edit: nevermind, i got it loaded and working in game finally. Only issue is it's not the solution i was hoping for. Looks like i'll need a more complicated solution. MeleeRangeCheck only checks distance, not angle or anything like that, so even if you are standing behind the attacking enemy as they attack, you still get hit. That's not gonna fly. Looks like i'll need to make a script for checking range and position as well.
Last edited by deathzero021 on Wed Nov 13, 2019 5:18 pm, edited 1 time in total.
User avatar
deathzero021
 
Joined: 24 Apr 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Simple Zscript issue

Postby Matt » Wed Nov 13, 2019 5:17 pm

deathzero021 wrote:And if we can't extend it, than how do we add any functions? Do we have to add it directly to a class we define?
Yes, but you could make the function static and call e.g. "MyClass.MyFunction(...)" from an unrelated class (as long as there's no scope conflict).

There's also something about "mixins" in the devbuilds but I've never tried using them before.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia


Return to Scripting

Who is online

Users browsing this forum: No registered users and 4 guests