
EDuke32 Scripting "CON coding help"
#2237 Posted 21 February 2018 - 01:44 PM
Yes, it's only for aplayer, but are you sure that the squish sound related to velocity, not to the height travelled by object?
I think it's possible to control the velocity of a sprite falling by using htcgg structure member.
@Trooper Dan
Nope, it works differenty. I'll try to explain in details. When the actor faces the situation when distance from the floor is more than 320, it starts falling and goes to the 1st frame of DYING animation. It continues to fall (dying anim constantly resets to its start frame), and when floordistance is less than 8, it checks with getzrange if the picnum below is a water. If not, then it "releases" DYING animation, and the actor is dying normally. If it is water below, it changes DYING anim to a "zero ai" or default STANDING action, and actor becomes alive, and behaves normally. Everything is ok except that in the case 2, if I kill that actor after he has fallen and was saved by water, he plays "squish" sound on death in addition to normal dying yell.
And I can't understand how "fall" works. I know of "htcgg", but sometimes actors fall faster or slower, in different situations. For example, my test actor is falling to the ground much slower, than to the water. (Probably smth related to the sectors? Idk)
This post has been edited by Mere_Duke: 21 February 2018 - 01:45 PM
#2238 Posted 21 February 2018 - 04:57 PM
Mere_Duke, on 21 February 2018 - 01:44 PM, said:
Nope, it works differenty. I'll try to explain in details. When the actor faces the situation when distance from the floor is more than 320, it starts falling and goes to the 1st frame of DYING animation. It continues to fall (dying anim constantly resets to its start frame), and when floordistance is less than 8, it checks with getzrange if the picnum below is a water. If not, then it "releases" DYING animation, and the actor is dying normally. If it is water below, it changes DYING anim to a "zero ai" or default STANDING action, and actor becomes alive, and behaves normally. Everything is ok except that in the case 2, if I kill that actor after he has fallen and was saved by water, he plays "squish" sound on death in addition to normal dying yell.
And I can't understand how "fall" works. I know of "htcgg", but sometimes actors fall faster or slower, in different situations. For example, my test actor is falling to the ground much slower, than to the water. (Probably smth related to the sectors? Idk)
First, your sound bug: it is likely that the actor is falling on a water texture, but the sector was not actually lotag 1 (water sector). Thus, as far as the game is concerned, he fell on a regular floor and not water. I don't know where the falling death data is getting saved in the sprite structure, but clearly it is.
Second, your method is very complicated and will probably give you the wrong result in some situations. The easiest way to tell if an actor is falling is to simply check their zvel (positive means falling). I would try something like this:
gamevar falltime 0 2 define FALLDAMAGETIME 24 // number of tics of falling before landing will hurt define FALLDAMAGEMULT 3 state fallaction // this is a placeholder state for changing the actor's action appropriately // you will want to change the action to the falling action when falltime >= FALLDAMAGETIME ends state checkfall ifg sprite[].zvel 0 { add falltime 1 state fallaction } else { ifg falltime FALLDAMAGETIME { ifonwater nullop else ifinwater nullop else { sub falltime FALLDAMAGETIME mul falltime FALLDAMAGEMULT seta[].htextra falltime seta[].htpicnum KNEE seta[].htowner THISACTOR sound SQUISHED guts JIBS6 4 // or whatever you want } } set falltime 0 } ends
The idea is that you want the actor to use the checkfall state whenever he's not already dead. It will determine whether he is falling, count how long he has been falling and apply damage depending on the length of the fall once he hits ground. It will not apply damage if he falls on a water sector.
#2239 Posted 21 February 2018 - 05:45 PM
The annoying SQUISH I couldn't catch is playing at 3rd enemy death. 2nd death is "wtf" as well

This post has been edited by Mere_Duke: 21 February 2018 - 05:47 PM
#2240 Posted 21 February 2018 - 06:12 PM
Maybe you get lucky and stopsound will stop it fast enough so you don't hear it
This post has been edited by Mark.: 21 February 2018 - 06:14 PM
#2241 Posted 21 February 2018 - 06:15 PM
ifactor MYCULTISTGUY { // blah blah blah change the action } else ifactor LIZTROOP { // blah blah blah change the action } // ... and so on
EDIT: on the squish sound, I don't really want to speculate about it because it could either be a hardcoded thing interacting with your code or there could be something else in your code causing it. Without looking at all of the relevant code, it's hard to say
This post has been edited by Trooper Dan: 21 February 2018 - 06:17 PM
#2242 Posted 21 February 2018 - 06:24 PM

#2243 Posted 21 February 2018 - 06:29 PM
Mark., on 21 February 2018 - 06:24 PM, said:

Your suggestion about stopping the sound when ifonwater would probably work, but I would first want to know what the root cause is and only do that as a last resort. Also, you would want to use "ifonwater ifactorsound THISACTOR SQUISHED stopactorsound THISACTOR SQUISHED". That's because the more general command "stopsound" will stop any instance of the sound, including instances legitimately started by another actor.
#2244 Posted 21 February 2018 - 06:47 PM
Oh, I completely forgot that I can determine actors with "ifactor". Need to stop trying to do everything via gamevars.
Now I at least understand why in Attririon you collected all monster ai's and action's in one place.
The SQUISH bug is not code-related 100%. I tried another place and found no such issues. Let's just leave it at that.
@Mark
stopsound will stop all sounds of that kind in a map - bad solution.
stopactorsound THISACTOR SQUISHED will stop this exact squish sound but it will also stop a sound of exploding body
EVENT_SOUND is the best way to catch it I think, but anyway it's a "kludge".

This post has been edited by Mere_Duke: 21 February 2018 - 06:48 PM
#2245 Posted 21 February 2018 - 07:08 PM
Mere_Duke, on 21 February 2018 - 06:47 PM, said:
But you would also be checking ifonwater
Also, if you check this stuff before ifhitweapon, then that won't be an issue because in the exploding body case you use killit and then there is no actor to run the code which would stop sound on the next tic
#2246 Posted 21 February 2018 - 07:39 PM
Trooper Dan, on 21 February 2018 - 07:08 PM, said:
But if actor will walk out of the water, this won't stop the sound. But anyway it only happens for a single sector. The problem is not code-related, as I thought before. Both ways (mine & yours) work, but I prefer yours. Thx for that.
#2247 Posted 24 February 2018 - 08:14 AM
Is there any way to create a hitbox for a sprite? I have a tree sprite, and want bullets to pass through leaves but hit a trunk. So far I just spawn a tall&thin sprite with a cstat of 32768+257 in the center of that tree to simulate a trunk, and set a tree cstat to 0.
#2248 Posted 24 February 2018 - 07:29 PM
#2249 Posted 25 February 2018 - 04:59 AM
Mere_Duke, on 24 February 2018 - 08:14 AM, said:
I don't understand what you are asking. A projectile is also a sprite, and it has a picnum just like any other sprite. It's not clear what you are trying to say. "catch them" sounds like a euphemism of some kind.
Mere_Duke, on 24 February 2018 - 08:14 AM, said:
I can only think of 2 methods off the top of my head. Method one is you define the actor with a sprite that has the actual hitbox you want, and then use an action to make it look different from its hitbox. Method 2 is what you describe -- make the actor nonhittable but make it spawn one or more proxy sprites with hitboxes that you want and make them transfer damage to the actor.
btw my internet is down at home and I can only be online for 5 minutes a day until it is fixed so that is all I can manage for now.
#2250 Posted 25 February 2018 - 07:59 PM
#2251 Posted 01 March 2018 - 11:28 AM
but when I put it in the def file.
I get
"Invalid frame name on line"
model "custom/19712_mushroom.md3" { scale 1 skin { pal 0 file "custom/19712_mushroom.png" } frame { name "Frame0" tile 19712 } }
What I am doing wrong?
Error logs
===============================
Mapster32 r6710
Built Feb 26 2018 17:17:23, GCC 7.2.0, 64-bit
Running on Windows 10 (build 10.0.16299)
Initializing SDL 2.0.7
Using C:/$$ EDUKE32 HRP $$/ for game data
Executing "m32_settings.cfg"
Searching for game data...
Found no recognized game data!
Using "DUKE3D.GRP" as main game data file.
Using group file "autoload/duke3d_hrp.zip".
Using group file "autoload/duke3d_music-sc55.zip".
Loading "m32help.hlp"
Error initializing integrated help: file "m32help.hlp" not found.
0 joystick(s) found
Initialized 24.0M cache
Loading "duke3d.def"
Polymer High Resolution Pack (version 5.4.674)
.............................Invalid frame name on line highres/sprites/z_custom.def:8
Removing model 417 due to errors.
...................................................
Definitions file "duke3d.def" loaded.
Setting video mode 800x600 (8-bpp windowed)
Refresh rate: 60Hz
Trying SDL_Renderer "direct3d"
Loading sounds from "GAME.CON"
warning: duplicate sound #261, overwriting
warning: duplicate sound #323, overwriting
Loaded 374 sound definitions.
Wrote m32_settings.cfg
===============================
z_custom.def is the file where I put customized models
Both Duke and Mapster are set to polymer.
This post has been edited by Zaxtor: 01 March 2018 - 11:29 AM
#2252 Posted 01 March 2018 - 11:37 AM
Frame1 is another popular default name. You can try that first if you wish.
This post has been edited by Mark.: 01 March 2018 - 11:39 AM
#2253 Posted 01 March 2018 - 12:01 PM
and no workin for model in def.
ill attach the file.
I tried Frame1.
Frame0
Imported object, says framecount 1, assuming is Frame1
I attached the thing.
Originally the "image file was tga but changed to png"
Theres 2 md3 files. I use the no1.
Dunno why 2 came, probably cus diff mushroom sizes.
Sprite origin is
https://www.katsbits...ll-mushroom.php
Attached File(s)
-
mushroon.rar (61.47K)
Number of downloads: 522
This post has been edited by Zaxtor: 01 March 2018 - 12:01 PM
#2257 Posted 01 March 2018 - 12:20 PM
#2258 Posted 14 March 2018 - 07:30 PM
if I do
useractor enemystayput SPRITENAMESTAYPUT SPRITENAMESTRENGTH
codes etc etc etc
cactor SPRITENAME
enda
Wont work.
I tried "setactor[THISACTOR].htactorstayput (var)"
they do nothing at all, mob walks out of sector,
Does that to customized mob (sprite from scratch) even if is a copy of an existing mob but with diff name.
What should we put in the code to make it work?
#2259 Posted 14 March 2018 - 07:50 PM
Zaxtor, on 14 March 2018 - 07:30 PM, said:
codes etc etc etc
cactor SPRITENAME
enda
That should work. To keep it simple, use
useractor enemystayput SPRITENAMESTAYPUT SPRITENAMESTRENGTH cactor SPRITENAME enda
and put ALL code in the regular actor or states used by regular actor. If you still can't get it to work, post your code for both actors, including which tile numbers you are using, all the move definitions, etc.
#2260 Posted 14 March 2018 - 08:02 PM
I made code to the stayput into a single line like u mentioned.
here is code
// Tormented pig action ATORMENTPWALK 0 4 5 1 20 action ATORMENTPRUN 0 4 5 1 11 action ATORMENTPSHOOT 30 2 5 1 58 action ATORMENTPCOCK 25 1 5 1 16 action ATORMENTPSTAND 30 1 5 1 1 action ATORMENTPDIVE 40 2 5 1 40 action ATORMENTPDIVESHOOT 45 2 5 1 58 action ATORMENTPDYING 55 5 1 1 15 action ATORMENTPHIT 55 1 1 1 10 action ATORMENTPDEAD 60 1 1 1 1 move TORMENTPWALKVELS 64 // standard is 72 pig is 11.1% slower move TORMENTPRUNVELS 96 // standard is 108 pig is 11.1% slower move TORMENTPSTOPPED ai AITORMENTPSEEKENEMY ATORMENTPWALK TORMENTPWALKVELS seekplayer ai AITORMENTPSHOOTENEMY ATORMENTPSHOOT TORMENTPSTOPPED faceplayer ai AITORMENTPFLEEENEMY ATORMENTPWALK TORMENTPWALKVELS fleeenemy ai AITORMENTPSHOOT ATORMENTPSHOOT TORMENTPSTOPPED faceplayer ai AITORMENTPDODGE ATORMENTPRUN TORMENTPRUNVELS dodgebullet ai AITORMENTPCHARGE ATORMENTPRUN TORMENTPRUNVELS seekplayer ai AITORMENTPDIVING ATORMENTPDIVE TORMENTPSTOPPED faceplayer ai AITORMENTPDYING ATORMENTPDYING TORMENTPSTOPPED faceplayer ai AITORMENTPHIT ATORMENTPHIT TORMENTPSTOPPED faceplayer state tormentseekenemystate ifai AITORMENTPCHARGE { ifcansee ifpdistl 3084 { ifnotmoving ai AITORMENTPSEEKENEMY else ai AITORMENTPDIVING } break } else iffloordistl 32 { ifpdistg 4096 { ifactornotstayput ai AITORMENTPCHARGE } ifrnd 8 { ifbulletnear ai AITORMENTPDODGE } } ifrnd 128 ifcansee { ifai AITORMENTPDODGE { ifcount 32 ai AITORMENTPCHARGE break } iffloordistl 32 { ifpdistl 1024 ifp palive ifcanshoottarget { ai AITORMENTPSHOOTENEMY break } ifcount 48 { ifrnd 8 ifp palive ifcanshoottarget { ifrnd 192 ai AITORMENTPSHOOTENEMY else ai AITORMENTPDIVING break } } } } ends state tormentshootenemystate { ifcount 12 nullop else ifcount 11 { ifcanshoottarget { sound PIG_ATTACK shoot SHOTGUN shoot SHOTGUN shoot SHOTGUN shoot SHOTGUN } else ai AITORMENTPSEEKENEMY } ifcount 25 nullop else ifcount 24 { action ATORMENTPCOCK sound SHOTGUN_COCK } ifcount 48 nullop else ifcount 47 { ifcanshoottarget { sound PIG_ATTACK shoot SHOTGUN shoot SHOTGUN shoot SHOTGUN shoot SHOTGUN } else ai AITORMENTPSEEKENEMY } ifcount 60 nullop else ifcount 59 { action ATORMENTPCOCK sound SHOTGUN_COCK } ifcount 72 { ifrnd 64 resetcount else { ifpdistl 768 ai AITORMENTPFLEEENEMY else ai AITORMENTPSEEKENEMY } } ifaction ATORMENTPCOCK ifactioncount 2 action ATORMENTPSHOOT } else ai AITORMENTPSEEKENEMY ends state tormentfleeenemystate ifactioncount 8 ai AITORMENTPSEEKENEMY else ifnotmoving ai AITORMENTPSEEKENEMY ends state tormentdivestate ifaction ATORMENTPDIVESHOOT { ifcansee { ifcount 12 nullop else ifcount 11 { ifcanshoottarget { sound PIG_ATTACK shoot SHOTGUN shoot SHOTGUN shoot SHOTGUN } else ai AITORMENTPSEEKENEMY } ifcount 25 nullop else ifcount 24 sound SHOTGUN_COCK ifcount 48 nullop else ifcount 47 { ifcanshoottarget { sound PIG_ATTACK shoot SHOTGUN shoot SHOTGUN shoot SHOTGUN } else ai AITORMENTPSEEKENEMY } ifcount 60 nullop else ifcount 59 { sound SHOTGUN_COCK ifgapzl 32 ai AITORMENTPDIVING else { ifpdistl 4096 ai AITORMENTPFLEEENEMY else ai AITORMENTPSEEKENEMY } } } else ifgapzl 32 ai AITORMENTPDIVING else ai AITORMENTPSEEKENEMY } else ifactioncount 2 ifp palive { resetcount action ATORMENTPDIVESHOOT } ends state checktormenthitstate spawn SMALLSMOKE ifdead { state random_wall_jibs ifrnd 16 spawn ATOMICHEALTH else state drop_shotgun ifwasweapon GROWSPARK { shoot GROWSPARK } addkills 1 ifwasweapon RADIUSEXPLOSION { cactor TORMENTDPIGDSPRITE } else ifwasweapon RPG { cactor TORMENTDPIGDSPRITE } else ai AITORMENTPDYING sound TPIG_DYING } else { sound TPIG_PAIN state random_wall_jibs ifwasweapon GROWSPARK sound EXPANDERHIT else ifrnd 32 ai AITORMENTPHIT else ifrnd 64 ai AITORMENTPSHOOTENEMY else ifrnd 64 { ai AITORMENTPDIVING action ATORMENTPDIVESHOOT } } ends state tormentdyingstate ifactioncount 5 { ifrnd 64 spawn SMALLSMOKE state rf iffloordistl 8 sound THUD action ATORMENTPDEAD move TORMENTPSTOPPED cactor TORMENTDPIGDSPRITE break } ends actor TORMENTDPIGSTAYSTILL TORMENTPIGSTRENGTH ifcanseetarget { ai AITORMENTPSEEKENEMY sound TPIG_RECOG cactor TORMENTDPIG } enda actor TORMENTDPIGDIVE TORMENTPIGSTRENGTH ai AITORMENTPDIVING action ATORMENTPDIVESHOOT cactor TORMENTDPIG enda useractor enemystayput TORMENTDPIGSTAYPUT TORMENTPIGSTRENGTH ai AITORMENTPSEEKENEMY cactor TORMENTDPIG enda actor TORMENTDPIG TORMENTPIGSTRENGTH ATORMENTPSTAND fall state checksquished ifaction ATORMENTPSTAND ai AITORMENTPSEEKENEMY else ifaction ATORMENTPDEAD { ifrespawn ifcount RESPAWNACTORTIME { spawn TRANSPORTERSTAR cstat 257 strength TORMENTPIGSTRENGTH ai AITORMENTPSEEKENEMY } else { strength 0 ifhitweapon ifwasweapon RADIUSEXPLOSION { cactor TORMENTDPIGDSPRITE } break } } else ifai AITORMENTPDYING state tormentdyingstate else ifai AITORMENTPHIT { ifactioncount 3 ai AITORMENTPSEEKENEMY } else { ifai AITORMENTPSEEKENEMY state tormentseekenemystate else ifai AITORMENTPDODGE state tormentseekenemystate else ifai AITORMENTPSHOOTENEMY state tormentshootenemystate else ifai AITORMENTPFLEEENEMY state tormentfleeenemystate else ifai AITORMENTPDIVING state tormentdivestate else ifai AITORMENTPCHARGE state tormentseekenemystate ifhitweapon state checktormenthitstate ifrnd 1 { ifrnd 32 soundonce TPIG_ROAM else ifrnd 64 { soundonce TPIG_ROAM2 } ifrnd 72 { ifcansee { spawn FIRESPREADOR spawn FIRESPREADOR } } else soundonce TPIG_ROAM3 ifrnd 94 { ifcansee { spawn FIRESPREADOR spawn FIRESPREADOR spawn FIRESPREADOR } } } } enda
This post has been edited by Zaxtor: 14 March 2018 - 08:10 PM
#2261 Posted 14 March 2018 - 08:10 PM
Was a test to make sure that part of the code works
#2262 Posted 14 March 2018 - 08:34 PM
Trooper Dan, on 14 March 2018 - 07:50 PM, said:
So which tile numbers are you using? If that actor overlaps the PIGCOP tiles, then that could be your problem.
#2263 Posted 14 March 2018 - 08:46 PM
I would'nt mind if it goes in other sectors with same tile as current tile as long he doesn't fall into the lava lol.
PS
At the moment the pig cop is alone in sector.
All others of his kind are in the same tile number as the one who is with stayput
This post has been edited by Zaxtor: 14 March 2018 - 08:48 PM
#2264 Posted 14 March 2018 - 10:31 PM
Try this. Instead of
actor TORMENTDPIG TORMENTPIGSTRENGTH ATORMENTPSTAND
useractor enemy TORMENTDPIG TORMENTPIGSTRENGTH ATORMENTPSTAND
_____________________________________________________
If that doesn't work, then just add the stayput code into the actor.
gamevar staysector -1 2 gamevar lastx 0 2 gamevar lasty 0 2 useractor enemystayput TORMENTDPIGSTAYPUT TORMENTPIGSTRENGTH cstat 257 geta[].sectnum staysector cactor TORMENTDPIG ai AITORMENTPSEEKENEMY enda // also edit this part of the main actor: useractor enemy TORMENTDPIG TORMENTPIGSTRENGTH ATORMENTPSTAND fall state checksquished ifn staysector -1 // stayput enemy { ife sprite[].sectnum staysector { geta[].x lastx geta[].y lasty } else { seta[].x lastx seta[].y lasty } } // rest of code as normal
#2265 Posted 14 March 2018 - 10:43 PM
Pig no longer "commits suicide"
thx
This post has been edited by Zaxtor: 14 March 2018 - 10:43 PM