EDuke32 Scripting "CON coding help"
#1441 Posted 31 March 2014 - 06:44 AM
#1442 Posted 31 March 2014 - 07:32 AM
MrGlasses, on 31 March 2014 - 06:44 AM, said:
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.
#1443 Posted 31 March 2014 - 07:33 AM
If player distance less than...
Dammit, Dan beat me
This post has been edited by Drek: 31 March 2014 - 07:34 AM
#1444 Posted 31 March 2014 - 09:30 AM
findnearspritevar TEMP 10241 TEMP2
Quote
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
#1445 Posted 31 March 2014 - 09:32 AM
#1446 Posted 31 March 2014 - 09:41 AM
Drek, 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.
#1447 Posted 31 March 2014 - 10:16 AM
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
#1448 Posted 31 March 2014 - 10:34 AM
Drek, on 31 March 2014 - 09:30 AM, said:
findnearspritevar TEMP 10241 TEMP2
Quote
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.
#1449 Posted 31 March 2014 - 10:38 AM
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
#1450 Posted 31 March 2014 - 10:55 AM
Drek, on 31 March 2014 - 10:38 AM, said:
In this case, it refers to the third
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.)
#1451 Posted 31 March 2014 - 11:06 AM
#1452 Posted 31 March 2014 - 01:10 PM
And up until a few years ago when the change was made you couldn't use constants for member function inputs.
#1453 Posted 18 April 2014 - 11:47 PM
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?
#1454 Posted 19 April 2014 - 12:09 AM
This post has been edited by James: 19 April 2014 - 12:10 AM
#1455 Posted 19 April 2014 - 12:37 AM
Trooper Dan, on 18 April 2014 - 11:47 PM, said:
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?
This post has been edited by Fox: 19 April 2014 - 03:45 AM
#1456 Posted 19 April 2014 - 03:19 AM
Trooper Dan, on 18 April 2014 - 11:47 PM, 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:
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 }
#1457 Posted 19 April 2014 - 03:59 AM
#1458 Posted 19 April 2014 - 04:01 AM
edit: efb, looks like Helix already has something planned heh heh.
This post has been edited by James: 19 April 2014 - 04:02 AM
#1459 Posted 19 April 2014 - 06:53 AM
James, on 19 April 2014 - 12:09 AM, said:
Thanks, but I tried that and it doesn't work in this case.
Fox, on 19 April 2014 - 12:37 AM, said:
I just tried that but it doesn't work. Checking game mode does what I want.
Helixhorned, on 19 April 2014 - 03:19 AM, said:
By the way, in the "damn I'm good" line, you have a trailing "else":
Fixed.
Helixhorned, on 19 April 2014 - 03:59 AM, said:
Thanks, I'll just wait for the fix to be committed then.
#1460 Posted 19 April 2014 - 09:04 AM
Helixhorned, on 19 April 2014 - 03:59 AM, said:
I've been doing 99% of the work in a separate file, so commit away.
#1463 Posted 22 April 2014 - 02:08 PM
Fox, on 19 April 2014 - 04:28 PM, said:
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.
#1464 Posted 22 April 2014 - 02:18 PM
Helixhorned, on 22 April 2014 - 02:08 PM, said:
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
#1465 Posted 01 May 2014 - 10:59 AM
This post has been edited by MrGlasses: 01 May 2014 - 11:00 AM
#1466 Posted 01 May 2014 - 11:06 AM
// 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 } }
#1467 Posted 01 May 2014 - 11:26 AM
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
#1469 Posted 01 May 2014 - 11:57 AM
#1470 Posted 01 May 2014 - 01:16 PM
Trooper Dan, on 01 May 2014 - 11:57 AM, said:
Yea, I used Fox's.