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

Jump to content

  • 124 Pages +
  • « First
  • 65
  • 66
  • 67
  • 68
  • 69
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   Danukem 

  • Duke Plus Developer

#1973

View PostDavid B., on 08 June 2017 - 12:09 PM, said:

flags 0 make it loops properly but indefinitely. For now it's the only case I know where animation is executed.


That's what it's supposed to do when flags is set to 0, but I was just asking to confirm you can get the animation to display.

I'm beginning to think we may have an EDuke32 bug here. Like I said, I experienced a similar problem. It seems that in many instances, setting flags 1 on an animation will cause it to immediately skip to the last frame rather than play the whole thing.
0

User is offline   David B. 

#1974

So I'm trying to fall back on a animation only with hardcoding, but the sprite still rotates roughly by 90.

(Here is what I wrote for now, but the while loop doesn't allow to looks like an animation. I even tried ifcount and resetcount inside the loop to make it changes the angle "step by step" but it makes the game bugs, thus I know all this is not the right solution) :

state rotate_door

  ifvare mycount 16     			
  {
    setvar mybool 1				
        setvar mycount 0			
  }     
  ifvare mybool 0 				
  {						
        addvar mycount 1 
  }     
  else
  ifvare mybool 1
        	
        ifpdistl 1024 ifhitspace {				
          
          setvar temp 512

             whilevarn temp 0 {

             getactor[THISACTOR].ang angnum
             addvar angnum 1
             
                   setactor[THISACTOR].ang angnum
                   subvar temp 1
                
                }

             }          

          ifvare temp 0 soundonce 412
          setvar mybool 0
                    	
        }  
ends		

useractor notenemy TEST_DOOR
  state rotate_door
enda
I'd like to assign to the sprite a rotating speed ; is it possible at least ?

This post has been edited by David B.: 11 June 2017 - 02:04 AM

0

User is offline   Kyanos 

#1975

Yes, it should be a simple math trick by manipulating your timing var (temp) and the rotation var (angvar)

Eg setting temp to 256 and adding 2 to angvar each tic would double speed.

Slower you could set temp to 1024 add 1 to angvar each tic then divvar angvar 2 before setting it to the sprite, this would give you half speed rotation.
0

User is offline   David B. 

#1976

View PostDrek, on 11 June 2017 - 08:27 AM, said:

Yes, it should be a simple math trick by manipulating your timing var (temp) and the rotation var (angvar)

Eg setting temp to 256 and adding 2 to angvar each tic would double speed.

Slower you could set temp to 1024 add 1 to angvar each tic then divvar angvar 2 before setting it to the sprite, this would give you half speed rotation.
This is not working precisely, the 512 loop tics (or 1024) are seemingly executed in "no time", what I just see in the game is the door taking suddenly the final position (ang + 512) after hit space ; tuning the speed has changed nothing.

I'd like to know a way to tell "wait a certain time" at the end of the loop. I used "ifcount" for that, but this crashes the game.
Or perhaps giving to the sprite a rotating velocity along the Z-axis, similarly to the linear velocity we may give by using xvel, yvel, zvel.

I can't think it's impossible to rotate a sprite but I need something which is unfortunately beyond my knowledge.

This post has been edited by David B.: 11 June 2017 - 09:44 AM

0

User is offline   Kyanos 

#1977

I will try to test this code block of yours myself later tonight. For now if I were you I'd try a few things, first I'd set up the sprite classically with actions, then try to work with ifactioncount for timing as it's probably the better route over game tics.

added later:
I reordered some brackets, but the worst offender for you was the while loop, it seemed to play out in 1 tic, I changed it to an ifvarn 0 then it cycles through now once each tic as event game is called, still not perfect it may animate at varying speeds for faster/slower pcs, I still recommend looking into using the actions and ifactioncount.
Attached File  test_door.zip (1.68K)
Number of downloads: 522

state rotate_door

  ifvare mycount 16                             
  {
    setvar mybool 1                             
    setvar mycount 0                        
  }     
  
  ifvare mybool 0                               
  {                                             
     addvar mycount 1 
  }    
  
  ifvare mybool 1 
  {
    ifpdistl 1024
    {	
      ifhitspace 
      { 
        setvar temp 512 // the way this is set up set temp here to full rotation you want
        getactor[THISACTOR].ang angnum
        setvar mybool 0
        soundonce 74
      }
    }
  }

  ifvarn temp 0 
  {
    addvar angnum 16 // set speed here 1 is slow, 2 is still slow but faster, use power of 2 nums
    setactor[THISACTOR].ang angnum
    subvar temp 16  // match this to angnum above, 4,8,16 maybe 32 are decent speeds
  }
ends            

useractor notenemy TEST_DOOR 
  state rotate_door
enda


This post has been edited by Drek: 11 June 2017 - 12:56 PM

1

User is offline   David B. 

#1978

View PostDrek, on 11 June 2017 - 09:58 AM, said:

I will try to test this code block of yours myself later tonight. For now if I were you I'd try a few things, first I'd set up the sprite classically with actions, then try to work with ifactioncount for timing as it's probably the better route over game tics.

added later:
I reordered some brackets, but the worst offender for you was the while loop, it seemed to play out in 1 tic, I changed it to an ifvarn 0 then it cycles through now once each tic as event game is called, still not perfect it may animate at varying speeds for faster/slower pcs, I still recommend looking into using the actions and ifactioncount.
I think I'm obliged to use the actions then.

This post has been edited by David B.: 12 June 2017 - 09:02 AM

0

User is offline   David B. 

#1979

Sorry to be a pain but the curse keeps on me... I'm using actions, here again the animation doesn't start neither and the door don't move.

action OPENING 1 9 1 1 4

useractor notenemy TEST_DOOR TOUGH OPENING

     ifpdistl 1024 ifhitspace ifcansee
     {
         soundonce 412
         action OPENING 

     }
 
enda


define TEST_DOOR		5646

and
dummytile 5646 128 128
   texture 5646 { 
   pal 0 { file "fx/door.jpg" }
   }

model "models/test/new test/door.md3" {
   scale 2 shade 4
   skin { pal 0 surface 0 file "models/test/door.jpg" }
   skin { pal 30 surface 0 file "models/test/door_30.jpg" }
   skin { surface 1 file "models/test/metal.jpg" }
   skin { surface 2 file "models/test/glass.png" }
   frame { name "closed1" tile 5646 }
   anim { frame0 "open1" frame1 "open2" fps 10 flags 1 }
   frame { name "open1" tile0 5647 tile1 5648 }
   }

This time I can't get animation even with flags 0. The issue seems to come from the action itself or something is lacking...
The action was supposed to play the 9 next frames, the first frame (closed1) being reserved for the closed door in its initial position (this trick is inspired from the EGG definition).
0

User is offline   Danukem 

  • Duke Plus Developer

#1980

The first thing that strikes me when looking at that is that you have an action that goes for 9 frames (from tiles 5647 to 5655) but your model definition only covers 2 of them.
0

User is offline   David B. 

#1981

View PostTrooper Dan, on 15 June 2017 - 10:08 AM, said:

The first thing that strikes me when looking at that is that you have an action that goes for 9 frames (from tiles 5647 to 5655) but your model definition only covers 2 of them.
Ok I understand that point, the definition has been modified as follows :

dummytile 5646 128 128
   texture 5646 { 
   pal 0 { file "fx/door.jpg" }
   }

model "models/test/new test/door.md3" {
   scale 2 shade 4
   skin { pal 0 surface 0 file "models/test/door.jpg" }
   skin { pal 30 surface 0 file "models/test/door_30.jpg" }
   skin { surface 1 file "models/test/metal.jpg" }
   skin { surface 2 file "models/test/glass.png" }

   frame { name "closed1" tile 5646 }

   anim { frame0 "open1" frame1 "open9" fps 10 flags 1 }
   frame { name "open1" tile0 5647 tile1 5655 }
   }

But I cannot control the door in the game yet. For the EGG, they put the animation on the second frame otherwise the animation would be played immediatly. I do the same here for my door but it seems the action don't fetch the frames for the animation.

This post has been edited by David B.: 15 June 2017 - 10:43 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#1982

action CLOSED 0 0 0 0 1
action OPENING 1 2 1 1 10

useractor notenemy TEST_DOOR TOUGH CLOSED

     ifaction CLOSED
     ifpdistl 1024 ifhitspace ifcansee
     {
         soundonce 412
         action OPENING 

     }
 
enda


I'm not sure, but try the above. It's more clear when you start with a defined action and then change to a different defined action only when the conditions are met.
0

User is offline   David B. 

#1983

View PostTrooper Dan, on 15 June 2017 - 11:21 AM, said:

I'm not sure, but try the above. It's more clear when you start with a defined action and then change to a different defined action only when the conditions are met.

The door still not working, I just hear the sound being played like the other times.
0

User is offline   Danukem 

  • Duke Plus Developer

#1984

View PostDavid B., on 15 June 2017 - 11:40 AM, said:

The door still not working, I just hear the sound being played like the other times.


I suspect that something is broken with displaying model animation in EDuke32 having to do with model flags. I recommend that you try old builds, like from 2 years ago, and see what happens. If you can get it to work with an older build then we can bisect it. The weird thing is that while I have had a similar problem myself, you don't see this happening with the HRP. If model flags were broken, then I would expect to see monster death animations not working.
0

User is offline   David B. 

#1985

View PostTrooper Dan, on 15 June 2017 - 11:50 AM, said:

I suspect that something is broken with displaying model animation in EDuke32 having to do with model flags. I recommend that you try old builds, like from 2 years ago, and see what happens. If you can get it to work with an older build then we can bisect it. The weird thing is that while I have had a similar problem myself, you don't see this happening with the HRP. If model flags were broken, then I would expect to see monster death animations not working.

I have re-installed duke3d (in a new folder) with an eduke32 version from 2014 (eduke32_win64_20140706-4538.7z) I had kept for a while but when I run the map, the behaviour is unfortunately the same.
Maybe the problem has always been there, or... the script seems to be OK but considering my low experience in hardcoding I'm not really sure.

This post has been edited by David B.: 15 June 2017 - 12:26 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#1986

View PostDavid B., on 15 June 2017 - 12:18 PM, said:

I have re-installed duke3d with an eduke32 version from 2014 (eduke32_win64_20140706-4538.7z) I had kept for a while but when I run the map, the behaviour is unfortunately the same.


Well so much for that theory...
0

User is offline   Kyanos 

#1987

It could be something simple like not setting dummytile for each tilenum.
2

User is offline   Danukem 

  • Duke Plus Developer

#1988

View PostDrek, on 15 June 2017 - 12:34 PM, said:

It could be something simple like not setting dummytile for each tilenum.


Good point. He only showed dummytile for the one tile instead of dummytilerange over all of them.
1

User is offline   David B. 

#1989

View PostDrek, on 15 June 2017 - 12:34 PM, said:

It could be something simple like not setting dummytile for each tilenum.
Incredible !!! Yes. That's it !

dummytilerange 5646 5655 128 128
   texture 5646 { 
   pal 0 { file "fx/door.jpg" }
   }

model "models/test/new test/door.md3" {
   scale 2 shade 4
   skin { pal 0 surface 0 file "models/test/door.jpg" }
   skin { pal 30 surface 0 file "models/test/door_30.jpg" }
   skin { surface 1 file "models/test/metal.jpg" }
   skin { surface 2 file "models/test/glass.png" }

   frame { name "closed1" tile 5646 }

   anim { frame0 "open1" frame1 "open9" fps 10 flags 1 }
   frame { name "open1" tile0 5647 tile1 5655 }
   }


The door opens now with a smooth animation, just by replacing dummytile by dummytilerange.

Nice idea;
1

User is offline   David B. 

#1990

I didn't know this point was so important...
0

User is offline   Danukem 

  • Duke Plus Developer

#1991

View PostDavid B., on 15 June 2017 - 12:42 PM, said:

I didn't know this point was so important...


You were trying to display animation on tiles that did not exist. When you define a tile range for a model, it's telling the game to draw the model instead of the 8-bit tiles that exist on those numbers. But if the tiles don't actually exist, then it won't work.
1

User is offline   Kyanos 

#1992

I've been a huge fan of Notepad++, especially with the CON language color scheme I got from here. But lately I've had a few specific text editing needs that put me onto Editpad. 1 It's a great hex editor with good copy/paste there. 2 "Regex" using REGular EXpressions in search and replace (pic related)
Posted Image
1

User is offline   Hendricks266 

  • Weaponized Autism

  #1993

I use Notepad++ for source code and EditPad for text that doesn't need highlighting. Both support regex in their find and replace.
0

User is offline   David B. 

#1994

Hi, I'm back again with another issue. I would like to define two actions and choose one depending on a gamevar.
I have tried many things before to come back here but this is for closing that damn door again.

gamevar closed 1 2

action OPENING 1 9 1 1 2
action CLOSING 9 9 1 -1 2 // (I tried also CLOSING 1 9 1 -1 2 but normally the closing starts from the last frame...)

useractor notenemy TEST_DOOR 0
    ifaction 0 {  // (I have read ifaction 0 allows to spare an action)
        ifpdistl 1024 ifhitspace ifcansee { 
            ifvare closed 1 {
                soundonce 412
                action OPENING
                cstat 0
                setvar closed 0
            } else {  // (now the part that seems to be ignored)
                soundonce 412
                action CLOSING
                cstat 1
                setvar closed 1
            }
        } 
    }    
enda

Opening is solved but nothing happens when I hit space for closing the door, the sound is not played neither so it ignores totally the second part of the script.
I tried also 'savegamevar' & 'readgamevar' for "closed 1" thinking it didn't record its value, with no result.

This post has been edited by David B.: 24 June 2017 - 05:27 AM

0

User is offline   Mark 

#1995

I'm a beginner level coder and my bracketing may be wrong but this is where I would start from. Basically you need the " ifaction OPENING" after the else which you were missing.


action CLOSING 1 9 1 1 2
action OPENING 9 9 9 -1 2 // I'm assuming your existing numbers are right

useractor notenemy TEST_DOOR TOUGH CLOSING

ifpdistl 1024 ifcansee ifhitspace

ifaction CLOSING
{
soundonce 412
action OPENING
}

else

ifaction OPENING
{
soundonce 412
action CLOSING
}

enda

This post has been edited by Mark.: 24 June 2017 - 06:51 AM

0

User is offline   David B. 

#1996

View PostMark., on 24 June 2017 - 06:17 AM, said:

I'm a beginner level coder and my bracketing may be wrong but this is where I would start from. Basically you need the " ifaction OPENING" after the else which you were missing.

action CLOSING 1 9 1 1 2
action OPENING 9 9 9 -1 2 // I'm assuming your existing numbers are right

useractor notenemy TEST_DOOR TOUGH CLOSING

ifpdistl 1024  ifcansee ifhitspace

ifaction CLOSING
{
soundonce 412
action OPENING 
}

else

ifaction OPENING
{
soundonce 412
action CLOSING 
}

enda 


For now I'm a beginner too (hope it's gonna change:) and I have difficulty especially with actions.
The problem is despite the number -1 I set in the CLOSING action, this changes nothing ; this is not playing the animation backward.

(Also the OPENING action (which works satisfactorily) doesn't change behaviour with 'start frame' ; 'number of tiles' or 'delay' parameters, which I don't understand neither. And if I set "-1" as incvalue the code still opens the door (still playing forward despite of -1 !).
Let's say I define 5 for the 'start frame' I should see my door starting suddenly from the 5th frame instead of playing the whole animation, right ?)
Calling an action "CLOSING" where I defined "-1" as incvalue should necessarily play the animation backward. So what happens here... ?

If this can help, I post again how my model was defined :
dummytilerange 5640 5649 128 128
   texture 5640 { 
   pal 0 { file "fx/door.jpg" }
   }

model "models/doors/door.md3" {
   scale 2 shade 4
   skin { pal 0 surface 0 file "models/doors/door.jpg" }
   skin { pal 30 surface 0 file "models/doors/door_30.jpg" }
   skin { surface 1 file "models/doors/metal.jpg" }
   skin { surface 2 file "models/doors/glass.png" }
   normal { surface 0 file "models/doors/door_n.jpg" }

   frame { name "closed1" tile 5640 }

   anim { frame0 "open1" frame1 "open9" fps 8 flags 1 }
   frame { name "open1" tile0 5641 tile1 5649 }
   }

When I see how hard it is for a door coding, the guys who have hard coded the monsters in the HRP version are really Kings !!

This post has been edited by David B.: 24 June 2017 - 07:24 AM

0

User is offline   Mark 

#1997

Another thing to do until you get it working is change the sound of door closing. That way if you hear the sound change each time you press the "use" key then you know that open/close code is working and the problem is in the action which moves the model.

EDIT: I see Drek is here. I also see a potential problem with my code suggestion. Save us!

This post has been edited by Mark.: 24 June 2017 - 01:42 PM

1

#1998

View PostDavid B., on 24 June 2017 - 05:27 AM, said:

Opening is solved but nothing happens when I hit space for closing the door, the sound is not played neither so it ignores totally the second part of the script.
I tried also 'savegamevar' & 'readgamevar' for "closed 1" thinking it didn't record its value, with no result.

It isn't supposed to happen, since all your code is placed inside the "ifaction 0" condition. Action 0 is the default action for an actor, which can be used to initialize its properties, and as soon as you switch to another action (opening animation), that code is never executed again. Your door actually should have four different states, as actor animations keep looping forever after reaching last frame. Use "ifactioncount" to check for the right time to stop opening animation and put the actor into a fixed opened state (separate action, 'closed' variable isn't needed), from which it can begin closing.

This post has been edited by Jan Satcitananda: 24 June 2017 - 10:10 PM

1

User is offline   David B. 

#1999

I'm not sure to understand everything but here's the new script I have done :

action OPENING 1 9 0 1 0
action CLOSING 1 9 0 -1 0

state open
    soundonce 450
    action OPENING
ends

state close // (opened)
    soundonce 455
    action CLOSING
    resetactioncount
ends

useractor notenemy TEST_DOOR 0

ifpdistl 1024 ifhitspace ifcansee {
    ifactioncount 0  { 
        state open
        break }

    else {
        ifactioncount 9 { 
            state close 
            
        }
    }
}

enda 


Only the first part is working before the else. Once the door is opened, I hear the same opening sound (450) when I hit space, not the closing sound (455). The door doesn't close.
The script executes each time the open state while actioncount should normally be incremented (or I think so).

This post has been edited by David B.: 26 June 2017 - 09:22 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2000

View PostDavid B., on 26 June 2017 - 09:21 AM, said:

Only the first part is working before the else.


The backwards animation defined with the -1 increment should begin on the tile where the first one ends, not on the same tile as the first one. Also, before going to state close you should be checking whether the action is action OPENING; you don't want it to loop the action CLOSING animation.

Good rule of thumb: if you are having trouble getting an animation to display, test the animation by itself before adding the animation to other code. More generally: when code isn't working and you can't figure out why, isolate the problem by testing individual components of the code. If you don't understand the individual components well enough to test them, then expect problems when you put them together.
1

User is offline   FezGuy 

#2001

Hi! Is there a way to add variety to the enemy sounds recognizing the player?

I'm creating human enemies. Instead of the enemies growling I want them to just say a few taunting lines. But I don't want them to say "Hey!" every time they see the player. It would get annoying and if I made each type of enemy say something different it would still get repetitive after awhile. It would be nice to get the trooper to say a random set of five lines so it has variety throughout the map. Same with the pig cop and lizard chain gunner guy., etc.

Is it just a line of code to add? I know how to define sounds in the game and know a little bit about .con files. Sometimes it's a matter of changing values. But this seems a little more detailed. Anybody have ideas?
0

User is offline   Kyanos 

#2002

That's a fairly easy task. If you quickly browse through GAME.CON you will find exactly what you're looking for, except it's for Dukes one liners. Look for jibbed actor sound.

To sum up, instead of playing the recog sound, you would use rand to generate a number then if statements that check the random number to determine which sounds to play.
0

Share this topic:


  • 124 Pages +
  • « First
  • 65
  • 66
  • 67
  • 68
  • 69
  • 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