> For the complete documentation index, see [llms.txt](https://sneakyevil.gitbook.io/sleeping-dogs-de-script-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sneakyevil.gitbook.io/sleeping-dogs-de-script-api/game-classes/simcharacter.md).

# SimCharacter

General game-character, properties & functions are derived from SimObject.

### Properties:

<table><thead><tr><th>Name</th><th width="200.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>FactionClass</td><td>integer</td><td>Enum: <a href="/sleeping-dogs-de-script-api/enums.md#factionclass">FactionClass</a></td></tr><tr><td>FightingClass</td><td>integer</td><td>Enum: <a href="/sleeping-dogs-de-script-api/enums.md#fightingclass">FightingClass</a></td></tr><tr><td>Gender</td><td>integer</td><td>Enum: <a href="/sleeping-dogs-de-script-api/enums.md#gender">Gender</a></td></tr><tr><td>Heading</td><td>float</td><td>Direction of facing</td></tr><tr><td>Health</td><td>integer</td><td>(0 to 400)</td></tr><tr><td>HealthMax</td><td>integer</td><td>-</td></tr><tr><td>Invulnerable</td><td>boolean</td><td>-</td></tr><tr><td>TakingDamage</td><td>boolean</td><td>-</td></tr><tr><td>Tired</td><td>boolean</td><td>-</td></tr></tbody></table>

### Static Functions:

#### .Create

`SimCharacter.Create(model: Hash, coords: Vector3, heading: float)`: SimCharacter

| Argument | Type    | Description                                                                             |
| -------- | ------- | --------------------------------------------------------------------------------------- |
| model    | Hash    | [More info](https://github.com/SDmodding/Script-Mod/blob/main/Info/CharacterModels.txt) |
| coords   | Vector3 | Position of new character                                                               |
| heading  | float   | Heading of new character                                                                |

Returns SimCharacter object when successfully created. Note: certain models can crash game!

#### .Get

`SimCharacter.Get(object: SimObject)`: SimCharacter

| Argument | Type      | Description     |
| -------- | --------- | --------------- |
| object   | SimObject | Valid SimObject |

This will cast SimObject to SimCharacter use this only if you know what you're doing!

#### .GetLocalPlayer

`SimCharacter.GetLocalPlayer()`: SimCharacter

Returns a SimCharacter object of localplayer (Wei Shen).

### Functions:

#### .SetAttackRights

`SimCharacter.SetAttackRights(toggle: boolean)`

| Argument | Type    | Description |
| -------- | ------- | ----------- |
| toggle   | boolean | -           |

Toggles attack rights. Note: by default most peds have no Attack Rights which means they cant be attacked by other peds neither they can attack them.

#### .GetTarget

`SimCharacter.GetTarget(type: TargetType)`: SimObject

| Argument | Type                                                           | Description |
| -------- | -------------------------------------------------------------- | ----------- |
| type     | [TargetType](/sleeping-dogs-de-script-api/enums.md#targettype) | -           |

#### .SetTarget

`SimCharacter.SetTarget(type: TargetType, object: SimObject)`

| Argument | Type                                                           | Description |
| -------- | -------------------------------------------------------------- | ----------- |
| type     | [TargetType](/sleeping-dogs-de-script-api/enums.md#targettype) | -           |
| object   | SimObject                                                      | -           |

#### .SetTargetLock

`SimCharacter.SetTargetLock(type: TargetType, lock: boolean, modifycollision: boolean)`

<table><thead><tr><th width="252">Argument</th><th width="133.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>type</td><td><a href="/sleeping-dogs-de-script-api/enums.md#targettype">TargetType</a></td><td>-</td></tr><tr><td>lock</td><td>boolean</td><td>-</td></tr><tr><td>modifycollision</td><td>boolean</td><td>Set true if interacting with physics object</td></tr></tbody></table>

#### .ClearTarget

`SimCharacter.ClearTarget(type: TargetType)`

<table><thead><tr><th width="252">Argument</th><th width="133.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>type</td><td><a href="/sleeping-dogs-de-script-api/enums.md#targettype">TargetType</a></td><td>-</td></tr></tbody></table>

### ActionNodes Functions:

#### .PlayActionNode

`SimCharacter.PlayActionNode(id: integer)`: boolean

<table><thead><tr><th width="252">Argument</th><th width="133.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>integer</td><td><a href="https://github.com/SDmodding/Files/tree/main/ActionNodes">More Info</a></td></tr></tbody></table>

Returns true if action was found and successfully queued for play.

#### .PlayActionNodeByName

`SimCharacter.PlayActionNodeByName(name: string)`: boolean

<table><thead><tr><th width="252">Argument</th><th width="133.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>name</td><td>string</td><td><a href="https://github.com/SDmodding/Files/tree/main/ActionNodes">More Info</a></td></tr></tbody></table>

Returns true if action was found and successfully queued for play. Note: this requires full path for action name and most of them might not be resolved so I recommend rather playing them by ID.

#### .StopActionNode

`SimCharacter.StopActionNode()`

Stop any currently playing action and restore to first action behavior the character started with.

### AI Functions:

#### .SetAIObjective

`SimCharacter.SetAIObjective(type: AIObjective)`

| Argument | Type                                                             | Description |
| -------- | ---------------------------------------------------------------- | ----------- |
| type     | [AIObjective](/sleeping-dogs-de-script-api/enums.md#aiobjective) | -           |

Sets a current AI Objective for SimCharacter.

### Bones Functions:

#### .GetBonesCount

`SimCharacter.GetBonesCount()`: integer

Returns number of bone count for SimCharacter. If character for some reason has no bone data it returns -1.

#### .GetBoneName

`SimCharacter.GetBoneName(index: integer)`: string

| Argument | Type    | Description |
| -------- | ------- | ----------- |
| index    | integer | -           |

Returns name of the bone of desired index, if this fails for some reason the return value will be null.

#### .GetBonePosition

`SimCharacter.GetBonePosition(bone: Hash)`: Vector3

| Argument | Type | Description |
| -------- | ---- | ----------- |
| bone     | Hash | -           |

Returns world position of the desired bone, if this fails return value is \[`0, 0, 0`].

#### .GetBoneRotation

`SimCharacter.GetBoneRotation(bone: Hash)`: Vector3

| Argument | Type | Description |
| -------- | ---- | ----------- |
| bone     | Hash | -           |

Returns rotation of the desired bone, if this fails return value is \[`0, 0, 0`].

### Prop Functions:

#### .AttachProp

`SimCharacter.AttachProp(prop: SimObjectProp, bone: CharacterBone, propbone: PropBone)`: boolean

| Argument | Type                                                                        | Description |
| -------- | --------------------------------------------------------------------------- | ----------- |
| prop     | [SimObjectProp](/sleeping-dogs-de-script-api/game-classes/simobjectprop.md) | -           |
| bone     | [CharacterBone](/sleeping-dogs-de-script-api/const.md#characterbone) (Hash) | (Optional)  |
| propbone | [PropBone](/sleeping-dogs-de-script-api/const.md#propbone) (Hash)           | (Optional)  |

Returns true when prop has been successfully attached to the character, this can fail if character or propr doesn't have default bone or when you specify own bone and it doesn't exist.

#### .DetachProp

`SimCharacter.DetachProp(prop: SimObjectProp)`: boolean

| Argument | Type                                                                        | Description |
| -------- | --------------------------------------------------------------------------- | ----------- |
| prop     | [SimObjectProp](/sleeping-dogs-de-script-api/game-classes/simobjectprop.md) | -           |

Returns true if prop has been successfully detached from the character.

### Vehicle Functions:

#### .GetOccupantState

`SimCharacter.GetOccupantState()`: [CharacterOccupantState](/sleeping-dogs-de-script-api/enums.md#characteroccupantstate)

Returns occupant state if SimCharacter is entering/exiting/sitting in some vehicle.

#### .GetCurrentVehicle

`SimCharacter.GetCurrentVehicle()`: [SimVehicle](/sleeping-dogs-de-script-api/game-classes/simvehicle.md)

Returns SimVehicle object if SimCharacter is occupant of any vehicle otherwise null.

#### .GetCurrentVehicleSeatIndex

`SimCharacter.GetCurrentVehicleSeatIndex()`: integer

Returns seat index if SimCharacter is occupant of any vehicle otherwise -1.

#### .PlaceInVehicle

`SimCharacter.PlaceInVehicle(vehicle: SimVehicle, seatIndex: integer)`: boolean

| Argument  | Type                                                                  | Description                   |
| --------- | --------------------------------------------------------------------- | ----------------------------- |
| vehicle   | [SimVehicle](/sleeping-dogs-de-script-api/game-classes/simvehicle.md) | -                             |
| seatindex | integer                                                               | 0 - Driver, 1...4 - Passenger |

Returns true if SimCharacter was successfully placed in vehicle, this can fail when seat is already occupied. <mark style="color:red;">Note: This will teleport character straight to the seat, there is no animation!</mark>

#### .ExitVehicle

`SimCharacter.ExitVehicle()`

Removes SimCharacter from current vehicle. <mark style="color:red;">Note: This will teleport character straight out of the vehicle, there is no animation!</mark>
