EDuke32 Scripting "CON coding help"
#1951 Posted 12 May 2017 - 03:25 PM
#1952 Posted 12 May 2017 - 04:09 PM
ifmove 0 { move YOURMOVE }in one of the events instead,
I don't know that this would make so much difference by now, though setting the VEL parameters immediately afterwards would certainly take a sprite up to full speed near enough instantly. Keep in mind that those values are in relation to the sprite's location in the map and not the orientation of the sprite - for example, rotating a sprite with a high XVEL will not change the way it moves, it will still move towards positive X on the map.
If you get stuck I'd be willing to take a quick look at what you're trying to do, as well as trying to make it work.
This post has been edited by High Treason: 12 May 2017 - 04:10 PM
#1953 Posted 12 May 2017 - 05:18 PM
High Treason, on 12 May 2017 - 04:09 PM, said:
That's not true. Sprites with a positive xvel member will move forwards (in the direction they are facing), whether it is on the x-axis of the map or not. I think you might be confusing this with using the internal clipmove function, or the movesprite CON command, which are different.
#1954 Posted 12 May 2017 - 05:51 PM
A cut-down version if you wish to observe this would be;
onevent EVENT_GAME ifactor APLAYER { setplayer[THISACTOR].xvel 102400 // Should be enough to make you move a little, but not fast enough to instantly smash into a wall. } endevent
I understand that the "ifactor" is redundant as I am using setplayer, but I use this "if" in my code because of other code that has to run exclusively in the APLAYER actor. I doubt it has any bearing at all, but it is included for consistency with what I have. Turning the player does not alter the direction in which they are traveling; A positive XVEL set this way serves to move the player towards positive X on the grid, regardless of which way they are facing.
This method is unusual for me anyway and is related to a specific purpose. Usually I just add/subtract X/Y/Z as I can safely assume the player won't be positioned outside of player space at any time the code is used.
#1955 Posted 12 May 2017 - 06:13 PM
High Treason, on 12 May 2017 - 05:51 PM, said:
That's because the player is different. For the player, there are posxv, posyv, and poszv members, all for speeds on the different planes. So yes, the player is the one entity in the game that works as you describe -- but we weren't talking about the player. We were talking about sprites that you can spawn. For regular sprites, positive xvel makes them move forward, negative makes them move backwards, positive zvel makes them move down, negative zvel makes them move up. And the yvel member on sprites is not used for velocity -- it has different purposes for different types of sprites.
#1956 Posted 12 May 2017 - 07:09 PM
I've noticed that some interesting things can happen if an actor's YVEL is manipulated and I am aware of some effects using it to store information. One such effect I discovered is actually useful in a map I've had shelved for years.
#1957 Posted 25 May 2017 - 10:52 AM
I'm trying to create an icon (sprite) with a script behind, its role is playing a sound (determined by the lotag) when the player is close to it and hits space.
But the sprite disappears in the game (I have seen the sprite is "annihilated" in the game because of the script behind, and the sprite has not been set as invisible) and nothing works as usual...
DEF FILE : dummytile 5970 24 24 texture 5970 { pal 0 { file "fx/icon_sound.jpg" } } DEFS.CON : define I_SOUND 5970 GAME.CON : gamevar snd 0 2 state playsnd ifpdistl 1024 ifhitspace { getactor[THISACTOR].lotag snd soundoncevar snd } ends useractor notenemy I_SOUND state playsnd enda
It's painful to do a single basic CON script that works... Some modders implement within their games new effects with icons (similar to S, M, T...) like in Dark Level. But despite my effort I can't figure out how they're doing this.
May I have some help to fix it ? It would be appreciated
#1958 Posted 25 May 2017 - 11:01 AM
eventloadactor I_SOUND getactor[THISACTOR].lotag snd setactor[THISACTOR].lotag 0 enda
Basically, you need to copy the lotag into a gamevar at map load, because otherwise the engine might do something to the sprite based on the number.
#1959 Posted 25 May 2017 - 12:12 PM
Hendricks266, on 25 May 2017 - 11:01 AM, said:
eventloadactor I_SOUND getactor[THISACTOR].lotag snd setactor[THISACTOR].lotag 0 enda
Basically, you need to copy the lotag into a gamevar at map load, because otherwise the engine might do something to the sprite based on the number.
But your solution works perfectly, thanks !
#1960 Posted 25 May 2017 - 01:02 PM
David B., on 25 May 2017 - 12:12 PM, said:
It's because lotag on sprites is used to determine whether they are deleted when the map loads. If the difficulty setting is lower than the tag, they get deleted.
#1961 Posted 25 May 2017 - 01:02 PM
This post has been edited by Mark.: 25 May 2017 - 01:04 PM
#1962 Posted 26 May 2017 - 12:15 PM
Mark., on 25 May 2017 - 01:02 PM, said:
#1963 Posted 30 May 2017 - 07:09 AM
This post has been edited by Mark.: 30 May 2017 - 09:26 AM
#1964 Posted 30 May 2017 - 11:19 AM
Mark., on 30 May 2017 - 07:09 AM, said:
You can do it the old fashioned way:
First, define a move that will be used like a var:
move WAIT
Then, in the actor's code, you do something like this (please excuse the shit formatting):
ifmove 0 ifp pfacing ifpdistl 1280 ifcansee move WAIT ifmove WAIT ifcount 30 action MYHOTACTION
#1965 Posted 30 May 2017 - 11:27 AM
This post has been edited by Mark.: 30 May 2017 - 11:37 AM
#1966 Posted 03 June 2017 - 12:37 PM
#1967 Posted 03 June 2017 - 01:06 PM
Perro Seco, on 03 June 2017 - 12:37 PM, said:
You can either have the player detect the type of projectile hitting him and reduce the damage when the owner of the projectile is not a player, or you can set the extra member on the projectile to a different amount after it is fired. The first option is not quite what you asked for, because the projectile would still do normal damage if an enemy shoots another enemy. So, focusing on the second option:
onevent EVENT_EGS ifspawnedby APLAYER nullop else { ifactor MYPROJECTILE strength 10 ifactor MYOTHERPROJECTILE strength 15 // etc. } endevent
If that doesn't work, try using setthisprojectile[].extra instead of strength.
#1968 Posted 04 June 2017 - 03:11 PM
#1969 Posted 04 June 2017 - 04:01 PM
Perro Seco, on 04 June 2017 - 03:11 PM, said:
I think you are confusing "strength" with "addstrength". Using negative values on "strength" should not work that way. In any case, what's going on here is that the .extra member of the projectile sprite, which stores damage, is being modified.
#1970 Posted 08 June 2017 - 05:44 AM
Drek, on 19 February 2017 - 12:46 PM, said:
Hello
I tried the script to open a door using an animated model. As a reminder, the closed door was a static model ("closed" position) while the next tile was defined as the same model with an animated opening.
The problem is when the model is switching to the next picnum to start the animation, the animation is not played but skips to the very last frame (completely opened).
As a result the door opens roughly anyway.
The behaviour is erratic because when I insisted on the door - opening & closing several times - it happens sometimes the animation is played (fluid opening),
and other times the animation goes "half-way". Is there some explanation or something to do ?
#1971 Posted 08 June 2017 - 10:03 AM
#1972 Posted 08 June 2017 - 12:09 PM
Trooper Dan, on 08 June 2017 - 10:03 AM, said:
#1973 Posted 08 June 2017 - 12:20 PM
David B., on 08 June 2017 - 12:09 PM, said:
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.
#1974 Posted 11 June 2017 - 02:03 AM
(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 endaI'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
#1975 Posted 11 June 2017 - 08:27 AM
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.
#1976 Posted 11 June 2017 - 09:43 AM
Drek, on 11 June 2017 - 08:27 AM, said:
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.
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
#1977 Posted 11 June 2017 - 09:58 AM
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.
test_door.zip (1.68K)
Number of downloads: 480
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
#1978 Posted 12 June 2017 - 09:02 AM
Drek, on 11 June 2017 - 09:58 AM, said:
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.
This post has been edited by David B.: 12 June 2017 - 09:02 AM
#1979 Posted 15 June 2017 - 09:51 AM
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).