Construction Set Scriptsammlung

damit könnte man doch bestimmt auch Türen machen, wie im Suprmarkt, die dann aufgehen, wenn man durch eine bestimmte Triggerbox geht?
-nur so als Frage...
 
Nochmal was Neues:

1. Ein Skript für eine Triggerbox, die nicht aktiviert werden soll, wenn der Spieler sie betritt, sondern wenn der Spieler sie verlässt:
Code:
scn TriggerLeaveSCRIPT

[COLOR="Red"];Written by Diarrhoe
;08/2010
;Checks, whether the player leaves a trigzone[/COLOR]


short triggered


Begin onTriggerActor player

if triggered
    return
endif
set triggered to 1
return

end

Begin GameMode

if triggered
    message "Spieler verlässt den Trigger!"     [COLOR="Red"];hier beliebigen Code einfügen[/COLOR]
    set triggered to 0
endif

end


2. Ein Skript für einen Trigger, bei dem der Spieler ein Objekt anschaut. Das Objekt ist das verlinkte "Parent" des Triggers:
Code:
scn DiarrhoeFloatTriggerLookAtParentSCRIPT

[COLOR="Red"];Written by Diarrhoe
;10/2010
;Makes the player once look at the trigger's parent and then slides the player's view over to the next parent[/COLOR]

short firstActivation
short triggered
short break
short finished

float timer
float secondsPassed

ref target

;-------------------
; constants
;-------------------

float pi
float half_pi
float radToDeg

float a0
float a1
float a2
float a3

float mod_ang_min
float timer_min
float timer_max
float timer_break

;-------------------
; movement control
;-------------------

float pos_x
float pos_y
float pos_z
float z_offset

float ang_x
float ang_z

float target_pos_x
float target_pos_y
float target_pos_z

float diff_pos_x
float diff_pos_y
float diff_pos_z

float radicand
float sqrt
float distance
float sine
short sign
float arcsine
float heading_ang_x

float diff_ang_x
float diff_ang_z
float diff_ges

float timer_start

float mod_ang_x
float mod_ang_z


Begin onTriggerActor player

if finished
  return
elseif triggered == 0
  if firstActivation == 0
    set firstActivation to 1

    set pi to 3.1415927
    set half_pi to 1.5707963
    set radToDeg to 57.2957795

    set a0 to 1.5707288
    set a1 to -0.2121144
    set a2 to 0.0742610
    set a3 to -0.0187293

    set mod_ang_min to 30
    set timer_min to 0.5
    set timer_max to 2.5
    set timer_break to 0.4
  endif

  set triggered to 1
  set break to 1
  set target to getParentRef
  if target
    disablePlayerControls
    player.setRestrained 1
  else
    set finished to 1
    return
  endif

  set pos_x to player.getPos x
  set pos_y to player.getPos y
  set pos_z to player.getPos z
  set z_offset to (player.getScale * (118 - 24*player.isSneaking))
  set pos_z to (pos_z + z_offset)

  set ang_x to player.getAngle x
  set ang_z to player.getAngle z
endif

end


Begin GameMode

if finished
  return
elseif triggered == 0
  return
endif

set secondsPassed to getSecondsPassed
if timer > 0
  set timer to (timer - secondsPassed)
  if break
    return
  endif
else
  if break
    set break to 0
  else
    set break to 1
    set target to target.getParentRef
    set timer to timer_break
    return
  endif

  if target
    set target_pos_x to target.getPos x
    set target_pos_y to target.getPos y
    set target_pos_z to target.getPos z

    set diff_pos_x to (pos_x - target_pos_x)
    set diff_pos_y to (pos_y - target_pos_y)
    set diff_pos_z to (pos_z - target_pos_z)

    set radicand to (diff_pos_x*diff_pos_x + diff_pos_y*diff_pos_y + diff_pos_z*diff_pos_z)
    set sqrt to (radicand / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set distance to ((sqrt + radicand/sqrt) / 2)

    set sine to (diff_pos_z / distance)
    if sine < 0
      set sine to -sine
      set sign to -1
    else
      set sign to 1
    endif
    set radicand to (1 - sine)
    set sqrt to (radicand / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set arcsine to (radToDeg * (half_pi - sqrt*(a0 + a1*sine + a2*sine*sine + a3*sine*sine*sine)))
    set heading_ang_x to (sign * arcsine)

    set diff_ang_x to ((heading_ang_x - ang_x) * 89 / 90)
    set diff_ang_z to player.getHeadingAngle target

    set radicand to (diff_ang_x*diff_ang_x + diff_ang_z*diff_ang_z)
    set sqrt to (radicand / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set sqrt to ((sqrt + radicand/sqrt) / 2)
    set diff_ges to ((sqrt + radicand/sqrt) / 2)

    set timer_start to (timer_min + diff_ges/(mod_ang_min + diff_ges/2.5))
    if timer_start > timer_max
      set timer_start to timer_max
    endif
    set timer to timer_start
    return
  else
    set finished to 1
    enablePlayerControls
    player.setRestrained 0
    return
  endif
endif

set mod_ang_x to (diff_ang_x * secondsPassed / timer_start)
set ang_x to (ang_x + mod_ang_x)
player.setAngle x ang_x

set mod_ang_z to (diff_ang_z * secondsPassed / timer_start)
set ang_z to (ang_z + mod_ang_z)
player.setAngle z ang_z

end


3. Ein Skript, dass den Spieler beim Passieren eines Triggers zu dessen "Parent" (z.B. ein X-Marker) teleportiert ohne Loop:
Code:
scn TriggerMoveToParentSCRIPT

[COLOR="Red"];Written by Diarrhoe
;10/2010
;Moves the player to the trigger's parent without loop[/COLOR]


short triggered
ref myParent


Begin onTriggerActor player

if triggered == 0
    set triggered to 1
    set myParent to getParentRef
    return
endif

end


Begin GameMode

if triggered
    set triggered to 0
    player.moveTo myParent
endif

end
 
Zuletzt bearbeitet: