
EDuke32 Scripting "CON coding help"
#2191 Posted 03 January 2018 - 08:33 AM
I'd like to know if someone could coded a "CRANE" but he uses the "locators" please ?
#2192 Posted 19 January 2018 - 04:14 AM
#2193 Posted 31 January 2018 - 05:37 PM
When you define level blah blah etc.
And you put part time and 3Drealm time the time you beat the level.
In the time can you exceed 99:59?
like let say 1:20:00 in the user con if the game mechanics will recognize it?
#2194 Posted 02 February 2018 - 10:22 PM
ifvare currentweapon 3 { ifvare player[THISACTOR].reloading 1 { ifvare reload_flag 0 { setplayer[THISACTOR].weapon_pos -1 // go down... setvar reload_flag 1 } addvar ak47_lower 1 ifvarvare player[THISACTOR].weapon_pos ak47_lower setvar low_flag 1 subvar ak47_lower 1 ifvare low_flag 1 setplayer[THISACTOR].weapon_pos ak47_lower // ...and stop at 'ak47_lower' frame and wait for the reloading to end } else { ifvare reload_flag 1 { mulvar ak47_lower -1 setplayer[THISACTOR].weapon_pos ak47_lower // go up 'ak47_lower' frames mulvar ak47_lower -1 setvar reload_flag 0 setvar low_flag 0 } } }
Are there any other way to do this? Maybe some specific variables or event? It works but I feel it isn't optimal approach.
This post has been edited by Mere_Duke: 02 February 2018 - 10:24 PM
#2195 Posted 02 February 2018 - 10:29 PM
ifvare currentweapon 3 { ifvare player[THISACTOR].reloading 1 { ifvare reload_flag 0 { setplayer[THISACTOR].weapon_pos -1 setvar reload_flag 1 } addvar ak47_lower 1 ifvarvare player[THISACTOR].weapon_pos ak47_lower // 'ak47_lower' frames down setvar low_flag 1 subvar ak47_lower 1 ifvare low_flag 1 setplayer[THISACTOR].weapon_pos ak47_lower } else { ifvare reload_flag 1 { mulvar ak47_lower -1 setplayer[THISACTOR].weapon_pos ak47_lower // 'ak47_lower' frames up mulvar ak47_lower -1 setvar reload_flag 0 setvar low_flag 0 } } }
Are there any other way to do this? Maybe some specific variables or event? It works but I feel it isn't optimal approach.
I mean, when I set weapon_pos to -1 it changes to -9 in a loop somewhere, can I somehow overload that loop and add there my own code? (I think it would be the best way.)
#2196 Posted 02 February 2018 - 10:43 PM
Mere_Duke, on 02 February 2018 - 10:29 PM, said:
I haven't looked at your code, but to answer this specific question: you can continually set weapon_pos to -9 to hold it there while your code does other things. Be aware that the player may switch weapons while this is happening, and in that case you should release the hold.
#2197 Posted 03 February 2018 - 04:41 AM
Trooper Dan, on 02 February 2018 - 10:43 PM, said:
Yeah, but if I continually set weapon_pos to -9 while ifvare player[THISACTOR].reloading 1, and release it after, then he won't be able to change weapon while it is lowered, will he? But what I need actually is to continually set weapon_pos to -6 and after make the weapon tile go not down but up. (If I just release it at -6 value, then the internal loop will decrement value from -6 to -9 what is exactly the thing I want to avoid.) The code above works perfectly but I feel it's just a dirty hack and there is a beautiful solution. Though I searched it such complex mods like Attrition or Nuclear Showdown and there is no such mechanics implemented.
I changed code to make it easier to read
ifvare currentweapon 3 { ifvare player[THISACTOR].reloading 1 { ifvare reload_flag 0 { setplayer[THISACTOR].weapon_pos -1 setvar reload_flag 1 } ifvarvare player[THISACTOR].weapon_pos -6 setvar low_flag 1 ifvare low_flag 1 setplayer[THISACTOR].weapon_pos -7 } else { ifvare reload_flag 1 { setplayer[THISACTOR].weapon_pos 7 setvar reload_flag 0 setvar low_flag 0 } } }
This post has been edited by Mere_Duke: 03 February 2018 - 04:48 AM
#2198 Posted 03 February 2018 - 10:37 AM
#2199 Posted 04 February 2018 - 05:37 AM
Another question, if you please.
The default game actor COMMANDER. Is there any hardcoded offset to make it float over ground? Is there any way to remove the offset if I want to replace commander with a walking enemy?
#2200 Posted 04 February 2018 - 08:22 AM
ifcansee
{
ifp phigher
move COMMGETUPVELS getv geth faceplayer
else
move COMMGETVELS getv geth faceplayer
}
might keep him from moving up or down. I saw the shark code tweaked to be used for spiders so it might be possible. I'm sure one of the smarter coders will be here to give a better answer.
This post has been edited by Mark.: 04 February 2018 - 08:23 AM
#2201 Posted 04 February 2018 - 09:38 AM
I assume there is something hardcoded related to some default game actors like DRONE or COMMANDER. Like the "enemy" tags of the some default actors which are hardcoded aswell.
The problem is not that he moves up or down but that he is floating above ground at the constant height. Like the default COMMANDER on his plate.
This post has been edited by Mere_Duke: 04 February 2018 - 09:42 AM
#2202 Posted 04 February 2018 - 10:05 AM

#2203 Posted 04 February 2018 - 11:48 AM
Mere_Duke, on 04 February 2018 - 09:38 AM, said:
The problem is not that he moves up or down but that he is floating above ground at the constant height. Like the default COMMANDER on his plate.
Yeah some of the enemies have hardcoded features like that. Just move your enemy to a different tile number. You don't even have to move the actual tiles, just define your enemy as some tile other than 1920 and then change the action definitions so that the animations look the same as before.
#2204 Posted 04 February 2018 - 06:15 PM
Trooper Dan, on 04 February 2018 - 11:48 AM, said:
Oh yeah, it works. Thx a lot! Is there any list of those hardcoded features? Like DRONE and COMMANDER are floating, BOSS2 always "move 0", etc etc? I am just fixing an old mod for NightFright's addon compilation and want to know of all possible flaws...
And Dan, please, tell me, where could I get the detailed CON syntax documentation? EDuke32 wiki have not every command described, for example, there is no "setav" command (only its "setactorvar" counterpart)...
P.S. Your activity it this thread is stunning, and thank you for all your great mods like DP, Attrition and WGR.
This post has been edited by Mere_Duke: 04 February 2018 - 06:17 PM
#2205 Posted 04 February 2018 - 07:23 PM
Mere_Duke, on 04 February 2018 - 06:15 PM, said:
And Dan, please, tell me, where could I get the detailed CON syntax documentation? EDuke32 wiki have not every command described, for example, there is no "setav" command (only its "setactorvar" counterpart)...
P.S. Your activity it this thread is stunning, and thank you for all your great mods like DP, Attrition and WGR.
I'm not aware of any place where the allowable abbreviations are documented, except perhaps in the dev notes on whatever revision they were introduced.
The big ones are:
[] can replace [THISACTOR] anywhere
set can replace either of the following: setvar, setvarvar
seta and geta can replace setactor and getactor
setp and getp can replace setplayer and getplayer
#2206 Posted 05 February 2018 - 06:02 AM
- You can use structure members as variables. For example spawnvar sprite[].hitag. Note that sprite is used instead of get/setactor.
- It's not necessary to differentiate between commands like setvar and setvarvar anymore. There's used to be a performance gain, but that's no longer the case. Use the command that can read gamevars.
- [] can replace [THISACTOR].
- The local actor, player or player distance can be set using vm_actor / vm_player / vm_distance. The value of THISCTOR usually equals vm_actor, but player[THISACTOR] equals vm_player. Commands like ifpdistl use vm_distance to determine the condition. Note that vm_distance is not always set by the game for performance reasons.
- You can loop using for. For example the code inside of for myvar allsprites {} will apply to all sprites. Note that you cannot use killit inside of this or it will break the loop. Using break / return may cause issues too. List of valid for values:
allsprites allspritesbystat allspritesbysect allsectors allwalls activelights / lights drawnsprites spritesofsector / sprofsec spritesofstatus / sprofstat loopofwall wallsofsector / walofsec range
Use range with NUMSECTORS / NUMWALLS / MULTIMODE to loop through all sectors, walls or players.
- Command aliases:
#define / define #include / include abs / klabs add / addvarvar al / addlogvar and / andvarvar array / gamearray ck / cheatkeys dc / definecheat div / divvarvar / divrd eqspawn / eqspawnvar eshoot / eshootvar espawn / espawnvar ezshoot / ezshootvar findnearactor / findnearactorvar findnearactor3d / findnearactor3dvar findnearactorz / findnearactorzvar findnearsprite / findnearspritevar findnearsprite3d / findnearsprite3dvar findnearspritez / findnearspritezvar geta / getactor getav / getactorvar geti / getinput getp / getplayer getpv / getplayervar gets / getsector getu / getuserdef getw / getwall ifa / ifvarvara ifae / ifvarvarae ifand / ifvarvarand ifb / ifvarvarb ifbe / ifvarvarbe ifboth / ifvarvarboth ife / ifvarvare ifeither / ifvarvareither ifg / ifvarvarg ifge / ifvarvarge ifl / ifvarvarl ifle / ifvarvarle ifn / ifvarvarn ifor / ifvarvaror ifxor / ifvarvarxor mod / modvarvar mul / mulvarvar or / orvarvar print / quote qputs / redefinequote qspawn / qspawnvar rand / randvarvar set / setvarvar seta / setactor setav / setactorvar seti / setinput setp / setplayer setpv / setplayervar sets / setsector setu / setuserdef setw / setwall shiftl / shiftvarvarl shiftr / shiftvarvarr shoot / shootvar string / definequote sub / subvarvar var / gamevar whilel / whilevarvarl whilen / whilevarvarn xor / xorvarvar zshoot / zshootvar
This post has been edited by Fox: 05 February 2018 - 06:15 AM
#2207 Posted 05 February 2018 - 09:06 AM
Fox, on 05 February 2018 - 06:02 AM, said:
It's still there, but it was always unimportant and is nothing that can't be fixed with a more advanced parser.
#2208 Posted 05 February 2018 - 11:05 AM
#2209 Posted 05 February 2018 - 11:14 AM
Fox, on 05 February 2018 - 06:02 AM, said:
- You can use structure members as variables. For example spawnvar sprite[].hitag. Note that sprite is used instead of get/setactor.
This is not a universally true statement. If I substitute a struct member in the place where a command normally outputs to a var, I get an error (at least for some commands). For example:
getangletotarget sprite[].ang
Can anyone explain the exact situations in which one can use structs in the place of vars?
#2210 Posted 05 February 2018 - 12:22 PM
#2211 Posted 05 February 2018 - 06:16 PM
Fox, on 05 February 2018 - 06:02 AM, said:
You mean that whenever I have to write "setvar patemp1 128", I may use "setvarvar patemp1 128" instead? Does this work the same way with the and/or/mul/etcvar commands?
Fox, on 05 February 2018 - 06:02 AM, said:
How should I use vm_actor/vm_player/vm_distance? Compiler doesn't recognize if I replace "player[THISACTOR]" with "vm_player". What exactly is a vm_* thing? Gamevar? Abbreviation? Structure? Structure pointer?
The list of other abbreviations is very useful, thanks a lot! It saved much of time

#2212 Posted 05 February 2018 - 07:57 PM
Fox, on 05 February 2018 - 06:02 AM, said:
This is far too advanced to be useful to beginners.
#2213 Posted 09 February 2018 - 05:50 AM
When I shoot a projectile with "shoot" command (eshoot FIRELASER, for example), or spawn a sprite with "spawn" command (spawn SHOTGUNSHELL, for example), I need to change the RETURN's spawn coordinates. I tried some ways: via RETURN reference (setactor[RETURN].x ...), in EVENT_SPAWN/EVENT_EGS, etc. It works, but I absolutely can't avoid that the sprite/projectile spawns for a frame (or two) in the default position, then "jumps" to the position I set it to. I assume that comes from the fact that the game manages to draw the sprite after it was created but before I changed its position. Are there any ways to preset spawn coordinates before the spawn, or where should I change them after they were set to defaults, but before sprite is ready to be drawn?
Thx in advance.
#2214 Posted 09 February 2018 - 05:59 PM
Mere_Duke, on 09 February 2018 - 05:50 AM, said:
When I shoot a projectile with "shoot" command (eshoot FIRELASER, for example), or spawn a sprite with "spawn" command (spawn SHOTGUNSHELL, for example), I need to change the RETURN's spawn coordinates. I tried some ways: via RETURN reference (setactor[RETURN].x ...), in EVENT_SPAWN/EVENT_EGS, etc. It works, but I absolutely can't avoid that the sprite/projectile spawns for a frame (or two) in the default position, then "jumps" to the position I set it to. I assume that comes from the fact that the game manages to draw the sprite after it was created but before I changed its position. Are there any ways to preset spawn coordinates before the spawn, or where should I change them after they were set to defaults, but before sprite is ready to be drawn?
Thx in advance.
Change the coordinates of the actor who is firing the projectile instead. Then, after firing, immediately (in the same block of code) change them back to the actor's original position. Since no time has actually passed, this will have no negative impacts.
#2215 Posted 09 February 2018 - 10:00 PM
Mere_Duke, on 09 February 2018 - 05:50 AM, said:
No, EVENT_EGS happens before the sprite is drawn. The game stores the old coordinates the previous coordinates of the object in the htbposx / htbposy / htbposz structures so the movement is interpolated (the game runs at 30 frames per second, but is drawn at 120 frames per second).
This is actually a problem with the original game, the most obvious case being the Overlord firing rockets.
This post has been edited by Fox: 09 February 2018 - 10:01 PM
#2216 Posted 09 February 2018 - 10:38 PM
Fox, on 09 February 2018 - 10:00 PM, said:
So you could just write to those in addition to changing the sprite's coords and that would solve the problem without moving the shooter. Good to know.
#2217 Posted 10 February 2018 - 01:46 PM
The problem is solved. Thank you, kind people.

This post has been edited by Mere_Duke: 10 February 2018 - 02:08 PM
#2218 Posted 12 February 2018 - 10:59 AM
For APLAYER we have "spritebridge" and "sbs" properties. The other actors don't have these.
How can I know if a actor is standing upon an "spritebridge"?
#2219 Posted 12 February 2018 - 12:01 PM
Make the spritebridge an actor and when your actor is within a certain distance in x,y,z plane do something.
#2220 Posted 12 February 2018 - 09:57 PM
http://wiki.eduke32.com/wiki/Getzrange
It's the same function called internally to check for stuff below when a sprite uses the fall command. One potential downside: since we know that sometimes actors will fall right through a sprite bridge when they have a downward momentum (this can be seen on jumping enemies) it's reasonable to wonder if getzrange will fail to detect the sprite bridge under similar circumstances.