Duke4.net Forums: EDuke32 Scripting - Duke4.net Forums

Jump to content

  • 119 Pages +
  • « First
  • 47
  • 48
  • 49
  • 50
  • 51
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   Jenz/Amaka 

#1441

I figured lot of things in Game.con, but there's something I just couldn't figure out. How do I make enemies shoot much more further away? rather than them coming almost right next to me and then shoot.
0

User is online   Danukem 

  • Duke Plus Developer

#1442

View PostMrGlasses, on 31 March 2014 - 06:44 AM, said:

I figured lot of things in Game.con, but there's something I just couldn't figure out. How do I make enemies shoot much more further away? rather than them coming almost right next to me and then shoot.


That can be trickier than it sounds. At your level of skill, I would suggest the following: Find all the places in the enemy code where it says "ifpdistl" Then check to see if it is being used as a condition for whether the enemy will start attacking, and if it is, double or triple the number that follows it.
1

User is offline   Kyanos 

#1443

Look for the con command ifpdistl
If player distance less than...

Dammit, Dan beat me

This post has been edited by Drek: 31 March 2014 - 07:34 AM

1

User is offline   Kyanos 

#1444

findnearspritevar TEMP 10241 TEMP2


Quote

ITEMS.CON:803: error: parameter `TEMP' is undefined.


I get an undefined error when trying to use a gamevar with findnearactorvar or findnearspritevar... Am I missing something?

from the wiki, http://wiki.eduke32....i/Findnearactor

Quote

Commands with an additional "var" suffix take gamevars rather than constants or defined labels for their inputs.

0

User is offline   Jenz/Amaka 

#1445

That did it. Pigcop was bit tricky to do but I managed it. They all move and shoot perfectly now, thanks!
0

User is online   Danukem 

  • Duke Plus Developer

#1446

View PostDrek, on 31 March 2014 - 09:30 AM, said:

findnearspritevar TEMP 10241 TEMP2




I get an undefined error when trying to use a gamevar with findnearactorvar or findnearspritevar... Am I missing something?

from the wiki, http://wiki.eduke32....i/Findnearactor


Do you have a var named "temp" declared but not "TEMP"? Remember that variable names are case sensitive.
0

User is offline   Kyanos 

#1447

Yes all the gamevars are properly declared.

Basically, I have an actor named STALFOS, defined to tile 7000. I've been using this as my test case, and just now wanted to expand on the code to include all enemies.

Code used to look like
useractor notenemy SPAWNER	
	findnearactor STALFOS 10241 TEMP2
    ifvare TEMP2 -1
	{
	espawnvar hitag
	killit
	}
enda

now looks like this;
useractor notenemy SPAWNER	
	setvar TEMP 7000
	findnearactorvar TEMP 10241 TEMP2
    ifvare TEMP2 -1
	{
	espawnvar hitag
	killit
	}
enda


I have tried things like setvarvar TEMP STALFOS, or I've defined lotag to 7000 in the map and used eventloadactor to retrieve that var, same results.

No matter what I do findnearactorvar returns an error if I use a gamevar.


ADDED:
I edited the end of GAME.CON to test this out in a purer workspace.
Changes made at line 8511, the NEWBEAST code. I get the same game startup error of TEMP being undefined.
gamevar TEMP 0 2
gamevar TEMP2 0 2

useractor enemy NEWBEAST NEWBEASTSTRENGTH
  fall
  ifaction 0
  {
    cstator 257
    sizeat 40 40
    ai AINEWBEASTDODGE
  }
  ifaction ANEWBEASTFROZEN
    state newbeastcode
  else
  {
    spritepal 6
    state newbeastcode
    ifaction ANEWBEASTFROZEN
      break
    getlastpal
  }
  
  setvar TEMP 2000
  findnearactorvar TEMP 10241 TEMP2
enda


This post has been edited by Drek: 31 March 2014 - 10:31 AM

0

User is offline   Helixhorned 

  • EDuke32 Developer

#1448

View PostDrek, on 31 March 2014 - 09:30 AM, said:

findnearspritevar TEMP 10241 TEMP2

Quote

ITEMS.CON:803: error: parameter `TEMP' is undefined.



I get an undefined error when trying to use a gamevar with findnearactorvar or findnearspritevar... Am I missing something?

The first argument to findnearspritevar is expected to be a literal number or a defined label, i.e. a translation-time constant. The word "parameter" hints at that, though I'd prefer the term "label" here.
0

User is offline   Kyanos 

#1449

Ok. Just that the wiki specifically said otherwise.

Commands with an additional "var" suffix take gamevars rather than constants or defined labels for their inputs

This post has been edited by Drek: 31 March 2014 - 10:40 AM

0

User is offline   Helixhorned 

  • EDuke32 Developer

#1450

View PostDrek, on 31 March 2014 - 10:38 AM, said:

Commands with an additional "var" suffix take gamevars rather than constants or defined labels for their inputs

In this case, it refers to the third input argument. Yeah, that sentence is worded a bit unfortunately.

Actually, on my few dabblings with CON, this was some source of annoyance indeed. Currently, LunaCON tries to match the requirements for the inputs to C-CON, but in cases like these, there's no reason for not accepting gamevars as well. I think I have stayed away from making it more liberal because that might imply issues in case there's a gamevar and a label with the same name. (Where gamevars are expected, they take precedence.)
0

User is online   Danukem 

  • Duke Plus Developer

#1451

A lot of the CON commands were modified a few years back to accept vars in places where constants had been required. I guess this wasn't one of them.
0

User is offline   Mblackwell 

  • Evil Overlord

#1452

Wasn't that the other way around: They accept constants where vars are asked for? You can't put a var in the second slot addvar <var> <somenumber> but you can put a constant for the second one in addvarvar <var> <var>.

And up until a few years ago when the change was made you couldn't use constants for member function inputs.
0

User is online   Danukem 

  • Duke Plus Developer

#1453

I'm trying to use EVENT_SOUND to get different sound numbers to play when the player selects a difficulty level. I'm using this code:

onevent EVENT_SOUND

ifvarand player[THISACTOR].gm 1
{
	ifvare RETURN JIBBED_ACTOR6 setvar RETURN BONUS_SPEECH1 else // piece of cake
	ifvare RETURN BONUS_SPEECH1 setvar RETURN DUKE_GETWEAPON2 else // let's rock
	ifvare RETURN DUKE_GETWEAPON2 setvar RETURN JIBBED_ACTOR5 else // come get some
	ifvare RETURN JIBBED_ACTOR5 setvar RETURN DAY2DIE else // DAMN I'M GOOD
}

endevent


What happens is that no sound plays at all, instead of playing the sound number of the new RETURN value. Any suggestions? I have already used addlogvar to confirm that RETURN has the expected values during the menu.

Any suggestions?
0

User is offline   Jblade 

#1454

There's a new con command called screensound which plays a sound unconditionally, that might do the trick.

This post has been edited by James: 19 April 2014 - 12:10 AM

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1455

View PostTrooper Dan, on 18 April 2014 - 11:47 PM, said:

I'm trying to use EVENT_SOUND to get different sound numbers to play when the player selects a difficulty level. I'm using this code:

onevent EVENT_SOUND

ifvarand player[THISACTOR].gm 1
{
	ifvare RETURN JIBBED_ACTOR6 setvar RETURN BONUS_SPEECH1 else // piece of cake
	ifvare RETURN BONUS_SPEECH1 setvar RETURN DUKE_GETWEAPON2 else // let's rock
	ifvare RETURN DUKE_GETWEAPON2 setvar RETURN JIBBED_ACTOR5 else // come get some
	ifvare RETURN JIBBED_ACTOR5 setvar RETURN DAY2DIE else // DAMN I'M GOOD
}

endevent


What happens is that no sound plays at all, instead of playing the sound number of the new RETURN value. Any suggestions? I have already used addlogvar to confirm that RETURN has the expected values during the menu.

Any suggestions?

You mixed the ifvare and setvar no? Also you should use "ifvare THISACTOR -1" instead of checking the game mode.

This post has been edited by Fox: 19 April 2014 - 03:45 AM

0

User is offline   Helixhorned 

  • EDuke32 Developer

#1456

View PostTrooper Dan, on 18 April 2014 - 11:47 PM, said:

I'm trying to use EVENT_SOUND to get different sound numbers to play when the player selects a difficulty level. I'm using this code:

Won't work with how things are coded now, unfortunately. When the menu starts a difficulty sound, it remembers the hard-coded sound number and displays the menu for as long as that one is playing:

menus.c:M_DisplayMenus()
            switch (x)
            {
            case 0:
                g_skillSoundID = JIBBED_ACTOR6;
                break;
(...)
            }

            S_PlaySound(g_skillSoundID);


premap.c:G_NewGame()
    if (g_skillSoundID >= 0 && ud.config.FXDevice >= 0 && ud.config.SoundToggle)
    {
        while (S_CheckSoundPlaying(-1, g_skillSoundID))
            G_HandleAsync();
    }


By the way, in the "damn I'm good" line, you have a trailing "else":

Quote

{
(...)
	ifvare RETURN JIBBED_ACTOR5 setvar RETURN DAY2DIE else // DAMN I'M GOOD
}


0

User is offline   Helixhorned 

  • EDuke32 Developer

#1457

Fixed in my local tree. Hendricks, are you prepared to merge minor changes in menus.c or would that throw off your work significantly?
0

User is offline   Jblade 

#1458

I was going to suggest moving those sounds and replacing them with blank files...but then I realised you might as well just move the new sounds into the existing difficulty sound slots and move those ones elsewhere.

edit: efb, looks like Helix already has something planned heh heh.

This post has been edited by James: 19 April 2014 - 04:02 AM

0

User is online   Danukem 

  • Duke Plus Developer

#1459

View PostJames, on 19 April 2014 - 12:09 AM, said:

There's a new con command called screensound which plays a sound unconditionally, that might do the trick.


Thanks, but I tried that and it doesn't work in this case.


View PostFox, on 19 April 2014 - 12:37 AM, said:

Also you should use "ifvare THISACTOR -1" instead of checking the game mode.


I just tried that but it doesn't work. Checking game mode does what I want.


View PostHelixhorned, on 19 April 2014 - 03:19 AM, said:

Won't work with how things are coded now, unfortunately. When the menu starts a difficulty sound, it remembers the hard-coded sound number and displays the menu for as long as that one is playing:

By the way, in the "damn I'm good" line, you have a trailing "else":


Fixed.


View PostHelixhorned, on 19 April 2014 - 03:59 AM, said:

Fixed in my local tree. Hendricks, are you prepared to merge minor changes in menus.c or would that throw off your work significantly?


Thanks, I'll just wait for the fix to be committed then.
0

User is online   Hendricks266 

  • Weaponized Autism

  #1460

View PostHelixhorned, on 19 April 2014 - 03:59 AM, said:

Fixed in my local tree. Hendricks, are you prepared to merge minor changes in menus.c or would that throw off your work significantly?

I've been doing 99% of the work in a separate file, so commit away.
0

User is offline   Helixhorned 

  • EDuke32 Developer

#1461

Committed the fix to r4449.

View PostTrooper Dan, on 19 April 2014 - 06:53 AM, said:

View PostFox, on 19 April 2014 - 12:37 AM, said:

Also you should use "ifvare THISACTOR -1" instead of checking the game mode.


I just tried that but it doesn't work. Checking game mode does what I want.

Yes, checking the game mode is preferable. The current actor may be invalid (i.e. -1) from other contexts, too.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1462

But getplayer is an invalid operation during the main menu...
0

User is offline   Helixhorned 

  • EDuke32 Developer

#1463

View PostFox, on 19 April 2014 - 04:28 PM, said:

But getplayer is an invalid operation during the main menu...

Who says that? Acutally, I kind of agree that it ought to be invalid in a certain sense, but in point of fact, it's not. What matters is that all events in question are entered with screenpeek as the "current player" (the one that getplayer[THISACTOR] refers to). This is the case for both instances of EVENT_SOUND (from S_PlaySound() and S_PlaySound3D()), as well as DISPLAYMENU and DISPLAYMENUREST, even though the latter two aren't even active when the difficulty sound is requested to be played and thus aren't relevant to the question.

One could object to various circumstances. First, why is player[].gm a player member when it's more like a property of a running EDuke32 instance than that of a player? Also, what meaning is there to EVENT_SOUND always getting screenpeek as the current player? Personally, I consider that event local -- game state must not depend on it being executed. Anyhow, what matters in a single-player setting that the event receives a valid player index at all -- player[0] is guaranteed to be valid even when no game is running, though it may not make sense to examine the values of most of its members then.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1464

I suppose .gm is a player structure because the menu being displayed or sending a message varies for each player in multiplayer.

View PostHelixhorned, on 22 April 2014 - 02:08 PM, said:

player[0] is guaranteed to be valid even when no game is running, though it may not make sense to examine the values of most of its members then.

I always assumed that no player existed in such events since per-player variables doesn't work well. I dunno about player structures.

This post has been edited by Fox: 22 April 2014 - 02:18 PM

0

User is offline   Jenz/Amaka 

#1465

I want to add more different sounds when enemies spot the player. I tried to find for example "PRED_RECOG" in GAME.con, but it ain't there. Where can I find "PRED_RECOG" or what do I have to type to add my own modifications?

This post has been edited by MrGlasses: 01 May 2014 - 11:00 AM

0

User is online   Hendricks266 

  • Weaponized Autism

  #1466

It's hardcoded. This is crappy but should have the same effect.

// top level
gamevar temp 0 0
gamevar temp2 0 0
gamevar flag 0 2

// in your main actor code:

    getactor[THISACTOR].httimetosleep temp
    getactor[THISACTOR].statnum temp2
    ifvare temp 0 ifvare temp2 1 // STAT_ACTOR
    {
        ifvare flag 0
        {
            sound PRED_RECOG
            setvar flag 1
        }
    }

1

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1467

Use EVENT_SOUND, something like this (for 3 sounds):

gamevar TEMP 0 0

onevent EVENT_SOUND
  ifvare RETURN PRED_RECOG
  {
    displayrandvar TEMP 2
    ifvare TEMP 1
      setvar RETURN PRED_RECOG2
    ifvare TEMP 2
      setvar RETURN PRED_RECOG3
  }
endevent

1

User is offline   Jenz/Amaka 

#1468

It worked!
Thank you!
0

User is online   Danukem 

  • Duke Plus Developer

#1469

@MrGlasses: you are referring to Fox's solution, right? I don't see how the code from Hendricks266 would do the job.
0

User is offline   Jenz/Amaka 

#1470

View PostTrooper Dan, on 01 May 2014 - 11:57 AM, said:

@MrGlasses: you are referring to Fox's solution, right? I don't see how the code from Hendricks266 would do the job.

Yea, I used Fox's.
0

Share this topic:


  • 119 Pages +
  • « First
  • 47
  • 48
  • 49
  • 50
  • 51
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options