Jump to content

Script for adding effects to player


ghostfc3s

Recommended Posts

I am looking at making an insanity system like frost/Grim

 

Both are nice mods but have some issues with them, however I like the concept of being in the wasteland having to kill for supplies and to stay alive will effect the SS's mental health.

 

I put together this script that runs as quest on start.

 

I am by no means a script person so this just kind of cobbled together with my limited knowlage. So i'm looking for some feedback on how to get this to work. \*I know how to make spells and magic effects to give visual layover of each effect its more about applying and removing the effects.

 

 

 

int KillCount = 0

 

Event Actor.OnKill(Actor akSender, Actor akVictim)

 

; Increment the number of kills.

 

KillCount += 1

 

EndEvent

 

 

 

; level one insanity

 

Event Killcount =< 25

 

ActorREF.Addspell(Para)

 

EndEvent

 

 

 

; Level two insanity

 

Even killcount =< 50

 

ActorREF.Addspell(PTSD)

 

EndEvent

 

 

 

; Level three insanity

 

Even killcount =< 75

 

ActorREF.Addspell(Insanity)

 

EndEvent

 

 

 

The healing effect I want to apply via a consumable.

 

 

 

Drink effect

 

 

 

set killCount = 0

 

ActorRef.RemoveSpell (Para)

 

ActorRef.RemoveSpell (PTSD)

 

ActorRef.RemoveSpell (Insanity)

 

 

 

Any thoughts and advice?

 

Would this be better to be handled via quest stages, when kill counter hits (25 move the stage to 20, 50 stage 30 )have it move to those stage then have the effects added at those stages, then have the cure set the quest back at stage 10 being the base line?

Edited by ghostfc3s
Link to comment
Share on other sites

I hope this helps:


;Properties 
Spell Property Para Auto
Spell Property PTSD Auto
Spell Property Insanity Auto
Potion Property HealingConsumable Auto

;declare KillCount
Int KillCount

Event OnQuestInit()
	;Initialize KillCount
	KillCount = 0
	
	;Register for Player events
	RegisterForRemoteEvent(Game.GetPlayer(), "OnKill")
	RegisterForRemoteEvent(Game.GetPlayer(), "OnItemEquipped")
EndEvent

Event Actor.OnKill(Actor akSender, Actor akVictim)
	; Increment KillCount
	KillCount += 1
	
	; level one insanity
	If Killcount <= 25
		akSender.Addspell(Para)
	; Level two insanity
	ElseIf Killcount <= 50
		akSender.Addspell(PTSD)
	; Level three insanity
	ElseIf Killcount <= 75
		akSender.Addspell(Insanity)
	EndIf
EndEvent

Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference)
	;Drink effect, check if equipped item is our healing consumable
	If akBaseObject Is Potion && (akBaseObject As Potion) == HealingConsumable
		; Reset KillCount
		KillCount = 0
		; Remove Spells
		akSender.RemoveSpell(Para)
		akSender.RemoveSpell(PTSD)
		akSender.RemoveSpell(Insanity)
	EndIf
EndEvent

Edit: I've changed the comparsion in the OnItemEquipped event, because it was comparing form with potion, which I think would fail. Note that I didn't tested anything.

Edited by DieFeM
Link to comment
Share on other sites

Note that I copied your logic, but A. it will apply the spells on each kill until the counter gets to 75, the comparsion should be == (equal to) instead of <= (less than or equal), so it applies the spells at 25, 50 and 75 kills and B. It will apply the 'level two' without removing the 'level one', and will apply the level three without removing levels one or two, you should handle that.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...