|
Development Forum |
 |
| How to Make an Object Float | |
|
 Air Guitarist
kezune
    

|
12/9/2013 | |
Hello again! New problem.
I'm making a toy this time and I've got an OK understanding of how to make it work but I want it to be able to float on water.
Is there a way to do this? Also, are there any resources online that detail all the CAOS codes, like values for bhvr and attr?
Updated Rehosting Policy[/title] |
 Mad Scientist
clohse
 

|
12/9/2013 | |
How about something like
doif rtype eq 8 or rtype eq 9
*fresh or salt water
accg 0
*no gravity
else
accg 1
*regular gravity
endi |
CLohse's Norns at the Creatures Repository |
 Air Guitarist
kezune
    

|
12/9/2013 | |
I like that, but I don't know how to get the room type that the agent's in. :C
Updated Rehosting Policy[/title] |
 Sanely Insane
RisenAngel
     Manager

|
12/9/2013 | |
Do you have Amai's Magic Words Room Edits? If you have that installed, you can type "rtype" and it'll give you the room type and corresponding number of the room the hand's in.
You can then plug in the number into this command:
And have your agent know what room it's in. In your case, you want room numbers 8 and 9 (fresh water and salt water, respectively).
Floating is a property that's rather tricky to get looking right, however. If you use something like the code clohse just posted, you're likely to have agents that look like they're jumping out of the water rather than floating. It's not something I'd recommend for a beginner.
To answer your second question, the CAOs Tool has a list of codes if you click on "Help" and then on either "Alphabetical Guide" or "Categorical Guide." Assuming you're using the CAOs Tool, anyway - if not, there's a CAOS command that'll give you the same documentation, but I don't remember it off the top of my head.
~ The Realm ~
Risen Angel's Creatures Blog
|
 Peppery One
Papriko
    
|
12/9/2013 | 1 |
In order to get the docs, Malkin made a resource article about it.
For the floating part... You could do the same I do when I want to find out how to achieve certain effects or actions: look for an agent which does something similar and tear the code into pieces.
I would recommend you to look at any fishy animal or the junk in the garbage dump. You can decompile agents using Monk.
But yeah, floating basically involves checking the room type and either drop like a stone or softly go up.
When you also check for positons slightly above your current one, you could even prevent bobbing up and down.
When in air, drop like a rock.
When in water with water above you, float up.
When in water with air above, stay at the current height.
Lets play plants! Photosynthesis... Photosynthesis... Photosynthesis... |

Malkin
     Manager

|
12/9/2013 | |
There's an article about attr and bhvr in this resource somewhere. 
My TCR Norns |

Malkin
     Manager

|
12/9/2013 | |
The beachball from Oasis looks like this:
********************************
* Beachball ********************
********************************
new: simp 2 21 24200 "moe_Oasis_beachball" 27 0 rand 1000 5000
attr 199
bhvr 1
elas 65
accg 2
aero 5
fric 15
perm 51
mvsf 780 46900
setv ov00 1
********************************
* Beachball ********************
********************************
scrp 2 21 24200 9
inst
setv va01 posb
subv va01 10
setv va00 rtyp grap posx va01
doif va00 eq 9 or va00 eq 8
accg -.15
elif va00 ne 9 and va00 ne 8
accg .75
setv va00 grid ownr down
doif rtyp va00 ne 9 and rtyp va00 ne 8
accg 2
tick 0
endi
endi
endm
scrp 2 21 24200 4
tick ov00
endm
scrp 2 21 24200 5
tick ov00
doif velx gt 0
mira 0
anim [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 255]
elif velx lt 0
mira 1
anim [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 255]
endi
endm
scrp 2 21 24200 1
*stim writ from NORN
stim writ from 97 2
setv va00 posx
targ from
doif posl lt va00
targ ownr
mira 0
velo rand 20 25 rand -20 -30
elif posl gt va00
targ ownr
mira 1
velo rand -20 -25 rand -20 -30
endi
targ ownr
anim [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 255]
tick ov00
endm
scrp 2 21 24200 6
sndc "bou3"
tick ov00
anim [ 16 17 18 19 20 21 22 23 24 25 26 ]
over
endm
scrp 2 21 24200 1001
endm |
For comparison's sake, here's the styrofoam cup from the Garbage Dump:
**Cup install
reps 5
inst
new: simp 3 8 4162 "toxic_foamcup" 2 0 rand 500 2000
attr 199
accg 4
bhvr 41
elas 5
aero 5
fric 100
mvsf rand 110 1150 7360
tick 1
repe
reps 2
inst
new: simp 3 8 4162 "toxic_foamcup" 2 0 rand 500 2000
attr 199
bhvr 41
accg 4
aero 5
elas 5
fric 100
mvsf rand 730 1150 7080
tick 1
repe
**Styro cup
scrp 3 8 4162 1
stim writ from 90 1
doif rtyp grap posx posb ne 9 and rtyp grap posx posb ne 8
setv vely -5
else
setv velx rand -10 10
endi
endm
scrp 3 8 4162 3
stim writ from 92 1
velo rand 5 -5 -10
endm
scrp 3 8 4162 4
stim writ from 91 1
endm
scrp 3 8 4162 6
setv va00 rand 0 2
endm
scrp 3 8 4162 9
doif carr ne null
pose 1
else
pose 0
endi
doif rtyp room ownr eq 8 or rtyp room ownr eq 9
accg 0
loop
wait 1
setv vely -1
doif carr ne null
stop
pose 1
else
pose 0
endi
setv va03 post
subv va03 -8
untl rtyp grap posx va03 ne 8 and rtyp grap posx va03 ne 9
loop
doif carr ne null
stop
pose 1
else
pose 0
endi
setv vely 0
wait 1
untl rtyp grap posx posb ne 8 and rtyp grap posx posb ne 9
else
accg 4
endi
endm |
It gets easier interpreting code once you've read through the CAOS documents.
You can see that the timer script is used for most of the floating magic (though I'd imagine the physics properties also has a great deal to do with it). Commands which look at the boundaries of your object, check if they're in the appropriate room type, then alter the gravity accordingly seems to be the way to go, as well as having a fairly fast tick (these examples have a timer which runs as often as is CAOTICALLY possible!) to restart the timer quickly. I might be missing some of the finer details here, I've never made a floating agent. Best of luck working it out! 
My TCR Norns |
 Air Guitarist
kezune
    

|
12/9/2013 | |
Thank you so much for the help, everyone. I've successfully made a floating toy using the Styrofoam cup as a guide. It could use some tweaking but it works fine. 
Updated Rehosting Policy[/title] |

Moe
  

|
12/11/2013 | 1 |
The good thing about the beach ball is it doesn't always have a fast tick. If you take it out of the water it goes back down to tick 0 to save professing power. The good thing about the cup is its use of loops. Finding a way to integrate the two is the best solution. There may be something like this coming in C2toDS soon.... |