home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CyberMycha 2006 April
/
SGP.iso
/
dema
/
Keepsake-Demo-en-li-v1.0.exe
/
res
/
bin
/
common
/
entity.tcl
< prev
next >
Wrap
Text File
|
2005-10-31
|
11KB
|
472 lines
proc hEntityMove { entity type pos event dist } {
if { "$event" == "wait" } {
ozEntity$entity $type [lindex $pos 0] [lindex $pos 1] [lindex $pos 2] "" 0
} else {
if { "$event" != "" && [getPlayerDistFrom [lindex $pos 0] [lindex $pos 1] [lindex $pos 2]] < $dist } {
callEvent "$event"
} else {
ozEntity$entity $type [lindex $pos 0] [lindex $pos 1] [lindex $pos 2] "$event" $dist
}
}
}
proc wizEntityGetPosition { entity } {
return [ozEntity$entity get position]
}
proc wizEntityGetClickPosition { entity } {
return [ozEntity$entity get clickposition]
}
proc wizEntitySetPosition { entity pos } {
ozEntity$entity set position [lindex $pos 0] [lindex $pos 1] [lindex $pos 2]
}
proc wizEntitySetPositionRelative { entity p1 q1 p2 q2 } {
set p1x [lindex $p1 0]
set p1y [lindex $p1 1]
set p1z [lindex $p1 2]
set q1x [lindex $q1 0]
set q1y [lindex $q1 1]
set q1z [lindex $q1 2]
set p2x [lindex $p2 0]
set p2y [lindex $p2 1]
set p2z [lindex $p2 2]
set q2x [lindex $q2 0]
set q2y [lindex $q2 1]
set q2z [lindex $q2 2]
set t [wizEntityGetPosition $entity]
set tx [lindex $t 0]
set ty [lindex $t 1]
set tz [lindex $t 2]
set r [ozSystem projection $tx $ty $tz $p1x $p1y $p1z $q1x $q1y $q1z]
set r [wizClamp $r 0 1]
set rx [wizRelative $r 0 1 $p2x $q2x]
set ry [wizRelative $r 0 1 $p2y $q2y]
set rz [wizRelative $r 0 1 $p2z $q2z]
wizEntitySetPosition $entity "$rx $ry $rz"
}
proc wizEntitySetOrientation { entity o } {
eval [subst {
ozEntity$entity set orientation [expr $o * [PI] / 180.0]
}]
}
proc wizEntityOrientation { entity o { event "" } } {
eval [subst {
ozEntity$entity orientation [expr $o * [PI] / 180.0] "$event"
}]
}
proc wizEntityMove { entity pos { event "" } { dist 10 }} {
hEntityMove $entity move "$pos" "$event" $dist
}
proc wizEntityWalk { entity pos { event "" } { dist 10 } } {
hEntityMove $entity walk "$pos" "$event" $dist
}
proc wizEntityRun { entity pos { event "" } { dist 10 } } {
hEntityMove $entity run "$pos" "$event" $dist
}
proc wizEntityAction { entity action } {
ozEntity$entity action $action
}
proc wizEntitySetSprintDistance { entity distance } {
ozEntity$entity set s[expr $a / $PI * 180.0]printDistance $distance
}
proc wizEntitySetSprintSpeed { entity speed } {
ozEntity$entity set sprintSpeed $speed
}
proc wizEntitySetWalkSpeed { entity speed } {
ozEntity$entity set walkSpeed $speed
}
proc wizEntityMoveXRelative { entity min max p q { event "" } { dist 10 } } {
set px [lindex $p 0]
set py [lindex $p 1]
set pz [lindex $p 2]
set qx [lindex $q 0]
set qy [lindex $q 1]
set qz [lindex $q 2]
set t [lindex [ozSystem getpanmouseclick] 0]
set t [expr ( 1 / ($max - $min) ) * ($t - $min)]
set t [wizClamp $t 0 1]
set x [wizRelative $t 0 1 $px $qx]
set y [wizRelative $t 0 1 $py $qy]
set z [wizRelative $t 0 1 $pz $qz]
wizEntityMove $entity "$x $y $z" "$event" $dist
}
proc wizEntityMoveYRelative { entity min max p q { event "" } { dist 10 } } {
set px [lindex $p 0]
set py [lindex $p 1]
set pz [lindex $p 2]
set qx [lindex $q 0]
set qy [lindex $q 1]
set qz [lindex $q 2]
set t [lindex [ozSystem getpanmouseclick] 1]
set t [expr ( 1 / ($max - $min) ) * ($t - $min)]
set t [wizClamp $t 0 1]
set x [wizRelative $t 0 1 $px $qx]
set y [wizRelative $t 0 1 $py $qy]
set z [wizRelative $t 0 1 $pz $qz]
wizEntityMove $entity "$x $y $z" "$event" $dist
}
proc wizqEntityMove { entity pos { event "" } { dist 10 } } {
eval [subst {
chainEvent {
wizEntityMove $entity "$pos" "$event" $dist
}
if { "$event" == "wait" } {
chainEvent {
if { \[ozEntity$entity isidle] == 0 } {
eventState wait
}
}
}
}]
}
proc wizqEntityWalk { entity pos { event "" } { dist 10 } } {
eval [subst {
chainEvent {
wizEntityWalk $entity "$pos" "$event" $dist
}
if { "$event" == "wait" } {
chainEvent {
if { \[ozEntity$entity isidle] == 0 } {
eventState wait
}
}
}
}]
}
proc wizqEntityRun { entity pos { event "" } { dist 10 } } {
eval [subst {
chainEvent {
wizEntityRun $entity "$pos" "$event" $dist
}
if { "$event" == "wait" } {
chainEvent {
if { \[ozEntity$entity isidle] == 0 } {
eventState wait
}
}
}
}]
}
proc wizqEntityAction { entity action { event "" } } {
eval [subst {
chainEvent {
wizEntityAction $entity $action
if { "$event" == "wait" } {
delay [wizEntityGetActionTime $entity $action]
}
}
}]
}
proc wizqEntitySetOrientation { entity o } {
eval [subst {
chainEvent {
wizEntitySetOrientation $entity $o
}
}]
}
proc wizqEntityOrientation { entity o { event "" } } {
eval [subst {
chainEvent {
if { "$event" == "wait" } {
wizEntityOrientation $entity $o
} else {
wizEntityOrientation $entity $o $event
}
}
if { "$event" == "wait" } {
chainEvent {
if { \[ozEntity$entity isidle] == 0 } {
eventState wait
}
}
}
}]
}
proc wizEntityAddCycle { entity cycle } {
ozEntity$entity addcycle $cycle
}
proc wizqEntityAddCycle { entity cycle} {
eval [subst {
chainEvent {
wizEntityAddCycle $entity $cycle
}
}]
}
proc wizEntityRemoveCycle { entity cycle } {
ozEntity$entity removecycle $cycle
}
proc wizqEntityRemoveCycle { entity cycle } {
eval [subst {
chainEvent {
wizEntityRemoveCycle $entity $cycle
}
}]
}
proc wizEntityLookAt { entity lookpos { event "" } } {
set entitypos [ozEntity$entity get position]
set ex [lindex $entitypos 0]
set ey [lindex $entitypos 1]
set ez [lindex $entitypos 2]
set lx [lindex $lookpos 0]
set ly [lindex $lookpos 1]
set lz [lindex $lookpos 2]
if {[expr abs($ex - $lx) + abs($ey - $ly) + abs($ez - $lz)] < 0.0001} {
return
}
set a [ozSystem mathangle $ex $ey $ez $lx $ly $lz]
wizEntityOrientation $entity [expr $a / [PI] * 180.0] "$event"
}
proc wizqEntityLookAt { entity lookpos } {
set entitypos [ozEntity$entity get position]
set ex [lindex $entitypos 0]
set ey [lindex $entitypos 1]
set ez [lindex $entitypos 2]
set lx [lindex $lookpos 0]
set ly [lindex $lookpos 1]
set lz [lindex $lookpos 2]
if {[expr abs($ex - $lx) + abs($ey - $ly) + abs($ez - $lz)] < 0.0001} {
return
}
set a [ozSystem mathangle $ex $ey $ez $lx $ly $lz]
wizqEntityOrientation $entity [expr $a / [PI] * 180.0]
}
proc wizEntityHide { entity } {
ozEntity$entity hide
}
proc wizEntityShow { entity } {
ozEntity$entity show
}
proc wizqEntityHide { entity } {
eval [subst {
chainEvent {
wizEntityHide $entity
}
}]
}
proc wizqEntityShow { entity } {
eval [subst {
chainEvent {
wizEntityShow $entity
}
}]
}
proc wizEntityStopFollow { entity } {
ozEntity$entity stopfollow
}
proc wizEntityResumeFollow { entity } {
ozEntity$entity resumefollow
}
proc wizqEntityStopFollow { entity } {
eval [subst {
chainEvent {
wizEntityStopFollow $entity
}
}]
}
proc wizqEntityResumeFollow { entity } {
eval [subst {
chainEvent {
wizEntityResumeFollow $entity
}
}]
}
proc wizEntityStop { entity } {
ozEntity$entity stop
}
proc wizqEntityStop { entity } {
eval [subst {
chainEvent {
wizEntityStop $entity
}
}]
}
proc wizEntityGetActionTime { entity action } {
return [ozEntity$entity get actiontime $action]
}
proc wizEntitySetCycle { entity cycle } {
ozEntity$entity setcycle $cycle
}
proc wizqEntitySetCycle { entity cycle} {
eval [subst {
chainEvent {
wizEntitySetCycle $entity $cycle
}
}]
}
proc wizEntitySetWalkSpeed { entity speed } {
ozEntity$entity set walkSpeed $speed
}
proc wizEntitySetSprintSpeed { entity speed } {
ozEntity$entity set sprintSpeed $speed
}
proc wizEntityGetWalkSpeed { entity } {
return [ozEntity$entity get walkSpeed]
}
proc wizEntityGetSprintSpeed { entity } {
return [ozEntity$entity get sprintSpeed]
}
proc wizqEntityChangeWalkSpeed { entity speed } {
if { $speed == "default" } {
eval [subst {
chainEvent {
if { \[info exists ::${entity}DefaultWalkSpeed] } {
wizEntitySetWalkSpeed $entity \[set ::${entity}DefaultWalkSpeed]
}
}
}]
return
}
eval [subst {
chainEvent {
if { !\[info exists ::${entity}DefaultWalkSpeed] } {
set ::${entity}DefaultWalkSpeed [wizEntityGetWalkSpeed $entity]
}
wizEntitySetWalkSpeed $entity $speed
}
}]
}
proc wizqEntityChangeSprintSpeed { entity speed } {
if { $speed == "default" } {
eval [subst {
chainEvent {
if { \[info exists ::${entity}DefaultSprintSpeed] } {
wizEntitySetSprintSpeed $entity \[set ::${entity}DefaultSprintSpeed]
}
}
}]
return
}
eval [subst {
chainEvent {
if { !\[info exists ::${entity}DefaultSprintSpeed] } {
set ::${entity}DefaultSprintSpeed [wizEntityGetSprintSpeed $entity]
}
wizEntitySetSprintSpeed $entity $speed
}
}]
}
proc wizEntitySetOrientationTarget { entity target } {
ozEntity$entity set target $target
}
proc wizqEntitySetOrientationTarget { entity target } {
eval [subst {
chainEvent {
wizEntitySetOrientationTarget $entity $target
}
}]
}
proc wizqEntityChangeCycle { entity cycle action { event "" } } {
eval [subst {
wizqEntityAction $entity $action
chainEvent { delay 250 }
wizqEntitySetCycle $entity $cycle
if { "$event" == "wait" } {
chainEvent {
delay [expr [wizEntityGetActionTime $entity $action]-250]
}
}
}]
}
proc wizqEntityEnableBackWalk { entity } {
eval [subst {
chainEvent { ozEntity$entity enablebackwalk }
}]
}
proc wizqEntityDisableBackWalk { entity } {
eval [subst {
chainEvent { ozEntity$entity disablebackwalk }
}]
}
proc wizqEntityModel { entity model} {
eval [subst {
chainEvent {ozEntity$entity model $model}
}]
}
proc wizqEntityFollowNormal { entity bool } {
eval [subst {
chainEvent {ozEntity$entity follownormal $bool}
}]
}