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

Jump to content

  • 115 Pages +
  • « First
  • 72
  • 73
  • 74
  • 75
  • 76
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   Aterbust 

#2191

Hello,
I'd like to know if someone could coded a "CRANE" but he uses the "locators" please ?
0

#2192

Hi everyone. Is it posible to create custom tag list (some list of values) for sprite in mapster32 and save it to .map file or separate file? I tried do use array but writearraytofile does not work from mapster32 script.
0

User is offline   Zaxtor 

#2193

In the definelevelname <episode> <levelnum> <mapname> <partime> <3dr> <levname>
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?
0

User is offline   Mere_Duke 

#2194

Hello everyone! I want to ask a probably simple CON question. What is the best place in code (player actor, a specific event, etc.) to manually control weapon_pos? I want to holster weapon a little during reload animation, wait some time and then put it back up as the reloading routine ends. I do it like that in APLAYER actor code block:
  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

0

User is offline   Mere_Duke 

#2195

Hello everyone! I want to ask a probably simple CON question. What is the best place in code (player actor, a specific event, etc.) to manually control weapon_pos? I want to holster weapon a little during reload animation, wait some time and then put it back up as the reloading routine ends. I do it like that in APLAYER actor code block:
  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.)
0

User is offline   Danukem 

  • Duke Plus Developer

#2196

View PostMere_Duke, on 02 February 2018 - 10:29 PM, said:

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.)


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.
0

User is offline   Mere_Duke 

#2197

View PostTrooper Dan, on 02 February 2018 - 10:43 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.

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

0

User is offline   Danukem 

  • Duke Plus Developer

#2198

Keep in mind that you don't actually have to use the hardcoded reloading or weapon_pos features. You can always just force kickback_pic to 0 and then manually draw the weapon to whatever position you want while using your own gamevars to count off wait times.
0

User is offline   Mere_Duke 

#2199

Yep, but it's redundant in my case.

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?
0

User is offline   Mark 

#2200

Just a wild guess. Using the fall command and modifying or cutting out stuff like this from his code

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

0

User is offline   Mere_Duke 

#2201

No, there is a completely reworked COMMANDER actor. It represents a walking soldier, and have no such moves like UPVELS, they are removed already. All the connection points with the default actor are the base sprite number (#1920) and the default game.con actor name (COMMANDER). Everything else is new. Soldier sprites have no offsets but they are drawn above the ground. Something like sprite[THISACTOR].z += 40.
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

0

User is offline   Mark 

#2202

I see. I thought maybe the fall command would keep him grounded. But that would be too easy. :dukecigar: Let me see if I can find that shark to spider code to see if there is anything relevant in there to your problem. It grounded the shark, maybe it can ground the commander.
0

User is offline   Danukem 

  • Duke Plus Developer

#2203

View PostMere_Duke, on 04 February 2018 - 09:38 AM, said:

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.


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.
0

User is offline   Mere_Duke 

#2204

View PostTrooper Dan, on 04 February 2018 - 11:48 AM, said:

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.

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

1

User is offline   Danukem 

  • Duke Plus Developer

#2205

View PostMere_Duke, on 04 February 2018 - 06:15 PM, 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.


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
1

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#2206

CON tips:

- 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

2

User is offline   Hendricks266 

  • Weaponized Autism

  #2207

View PostFox, on 05 February 2018 - 06:02 AM, said:

There's used to be a performance gain, but that's no longer the case.

It's still there, but it was always unimportant and is nothing that can't be fixed with a more advanced parser.
0

User is offline   Danukem 

  • Duke Plus Developer

#2208

A lot of that new stuff was only available in mapster script, but I guess it was quietly added to CON.
0

User is offline   Danukem 

  • Duke Plus Developer

#2209

View PostFox, 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?
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#2210

Indeed you cannot use values that set a variable on structures.
0

User is offline   Mere_Duke 

#2211

View PostFox, on 05 February 2018 - 06:02 AM, said:

- 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.

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?

View PostFox, on 05 February 2018 - 06:02 AM, said:

- The local actor, player or player distance can be set using vm_actor / vm_player / vm_distance. The value of THISACTOR 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.

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 :dukecigar:
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2212

View PostFox, on 05 February 2018 - 06:02 AM, said:

- 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.

This is far too advanced to be useful to beginners.
1

User is offline   Mere_Duke 

#2213

I need a little advice again.
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.
0

User is offline   Danukem 

  • Duke Plus Developer

#2214

View PostMere_Duke, on 09 February 2018 - 05:50 AM, said:

I need a little advice again.
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.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#2215

View PostMere_Duke, on 09 February 2018 - 05:50 AM, said:

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.

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

1

User is offline   Danukem 

  • Duke Plus Developer

#2216

View PostFox, on 09 February 2018 - 10:00 PM, 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 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.
0

User is offline   Mere_Duke 

#2217

htbpos+ works just fine (I thought it is undefined at that moment right after eshoot has been called and has no effect), as well as the moving an actor instead of its projectile.
The problem is solved. Thank you, kind people. :dukecigar:

This post has been edited by Mere_Duke: 10 February 2018 - 02:08 PM

0

User is offline   RPD Guy 

#2218

Someone knows?
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"?
0

User is offline   Mark 

#2219

Could using Findnearactor be of any help? http://wiki.eduke32....i/Findnearactor

Make the spritebridge an actor and when your actor is within a certain distance in x,y,z plane do something.
0

User is offline   Danukem 

  • Duke Plus Developer

#2220

You want to use this:

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.
0

Share this topic:


  • 115 Pages +
  • « First
  • 72
  • 73
  • 74
  • 75
  • 76
  • 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