Jump to content

Help Cast Function


OvadWolfeye

Recommended Posts

So I am trying to make a script that when I try to pick up an object a spell effect (aka curse) is put on the player. I looked at the Alter of Arkay script and the syntax it appears to use to cause this to happen to the player is Cast AltarArkay Player. Am I missing something or is it impossible to have a spell effect be placed on a player via scripting?

Link to comment
Share on other sites

It is possible for sure and I made some and the altars is good examples for this.

 

So if I am getting it right, the NPC that you are trying to loot, will curse you? The only thing that pops up in my mind right now is that the NPC should be scripted and I try to make an example...

scn DeadNPCCurseSCR

Begin Onactivate

 if ( GetDead )
   Cast AltarArkay Player
  endif

end

This also means that it gets impossible to open the dead NPC's inventory as if you want to do that, then Activate must be used after the if block as well like this:

scn DEADNPCCURSE

Begin Onactivate

 if ( GetDead )
   Cast AltarArkay Player
  endif

  activate 

end

There's some flags for activate as well, that I do not get for the moment but they seems to be used when other stuff tries to activate you...

Edited by Pellape
Link to comment
Share on other sites

Well, it's not "impossible" to put a spell effect onto the player directly, but it's way more complex to do. There's no simple function like "put spell effect on actor" or the like. It involves highly articulated OBSE scripting.

That's why nobody does it, when you can just as well make the thing you weren't to touch cast the spell onto you instead.

 

Mind, however, not all kinds/types of objects can cast a spell, even with scripting. They must be "activators" or related to them, like actors, doors, chests, etc., something you "can" activate in other words.

And for actors it's again special, as it will also make them do the casting animation, provided they have one, and if they don't have one, then they also can't be made to cast.

 

"OnActivate" is the proper block type to catch this activation. (The command isn't "Start" though but "Begin".)

It should also be checked who or what activated the "trap", if you don't want it casting the curse onto everyone. Or you can obtain the actual activator (who or what activated it) and cast the curse onto this.

The last thing you want is your player getting cursed, because some random beggar just happened to pick up the item while you were only close by.

 

One thing to mind when using the "Activate" function is the confusing order when going by its name.

It's "chest.activate player", meaning the player activates the chest,

not "player.activate chest", meaning the chest activates the player.

That's why in every OnActivate block that is to catch activation and either occasionally prevent it or not at all there's mostly only an "Activate" call at the end (meaning "activate myself" or "pass on my activation").

Link to comment
Share on other sites

Ok sorry guys for taking so long to reply this is what I am trying to do. I got a pair of boots that I want to have chameleon only while crouching.

I made a working pair that adds a ring with chameleon enchantment without a specified equipment slot. when in crouch item is added and equipped when nor item is unequipped and removed. it works, but I want it to work with a spell instead so I made a trigger and placed in a test cell the boots now when entering crouch mode use the moveto function to move the trigger to the player and the trigger is scripted

 

scn ovadbootstriggerscript

ref trigger

ref home

short triggered
float timer

begin onTrigger

set trigger to ovadbootstriggerref

set home to ovadtriggerhomeref
if triggered == 0
trigger.cast ovadbootsspell player
set triggered to 1
set timer to 2 ;2 delay before reset
endif
end

begin gameMode
if triggered == 1
if timer <= 0
set triggered to 0
else
set timer to timer - getSecondsPassed
endif
endif
end

 

 

 

I thought it might be a syntax error so I tinkered with it a bit to this :

 

Scn OvadBootsTriggerScript
short triggered
Ref Trigger
Ref Home
Begin OnTrigger Player
set trigger to OvadBootsTriggerRef
Set Home to OvadTriggerHomeRef
if triggered == 0
set triggered to 1
endif
end
begin gameMode
if triggered == 1
cast OvadBootsSpell Player
messagebox" test if working thus far"
set triggered to 2
endif
If Triggered == 2
trigger.moveto home
endif
End
so my player never gets the chameleon spell cast on him but the messagebox does appear. what am I doing Wrong?????
also the boots script has the if issneaking == 1 && DoOnce == 0 so that the boots do not just cause the trigger to repeatedly cycle between moveto functions.
Link to comment
Share on other sites

I think the spell is the problem. I do have a similar problem with an item that works like a shrine that I copied from another home mod, with permissions.

I canot see that anything is wrong with your script, but they get easier to read if you add them to a Code window like this with the blue <> button a bit up

Message "Hello World"
  • I think it fails to cast the spells if I am not close enough, even if it is a target spell.
  • Also check the duration of the spell as if it is set to 0, then it will most likely fail so set the time to 1 at least.
Edited by Pellape
Link to comment
Share on other sites

test run

ok hope that worked. thanks for info. I checked and my spell was set to Self. I changed this to Target. mag of chameleon on said spell is 30 and the duration is 5000. I reloaded game and tested the box popped up I clicked ok, then I hear the spell see a small green poof like my player farted ( no joke only the location of fart was not directly behind his rear) but no chameleon effect was put on player. I think its somewhere in my timing I have the cast function listed before the move to home. Do you think I need to ad a timer in-between these steps? Is the moveto function preventing the cast function to complete?

as far you saying a similar one you done was that the player to far away from the trigger, I have move to without coords so it should be right on top of my player. Could this effect the outcome possibly need to change it to trigger.moveto player 10,10,10 as an exmple?

 

bonus question if the blue <> didnt work correctly how do i get it to work correctly for future posts?

 

Test run blue<> #2

Scn OvadBootsTriggerScript
 
short triggered
Ref Trigger
Ref Home
 
 
 
Begin OnTrigger Player
set trigger to OvadBootsTriggerRef
Set Home to OvadTriggerHomeRef
if triggered == 0
set triggered to 1
endif
end
 
begin gameMode
  if triggered == 1
  cast OvadBootsSpell Player
messagebox" test if working thus far"
  set triggered to 2
 endif
 
If Triggered == 2
trigger.moveto home
endif
End
Edited by CountryRoberts
Link to comment
Share on other sites

Hmm, can a TriggerBox also cast spells? Can't recall having seen one used for that, yet.

But using a trigger for that is kinda overcomplicating things anyways. If I need to have a spell cast onto the player, or something else, from out of nowhere, I for one prefer using an Activator. There's even empty NIFs floating around somewhere, so there's also nothing to see in the split-second the activator is nearby.

So you have a script that spawns the triggerbox (triggerRef.MoveTo player), then you wait for the trigger to get triggered by being around the player only for then to do the casting from a script on the trigger itself.

You can just as well only use the one script you already have, spawn an activator instead, then use its ref for the casting call:

...
OvadBootsCasterRef.moveTo player ;add some offset as well, if needed, somewhere "above" the player is usually done
OvadBootsCasterRef.cast OvadBootsSpell player
OvadBootsCasterRef.moveTo OvadTriggerHomeRef
...

And that should also do the trick. The activator doesn't need any script to run on itself.


Also, you're using the code box correctly, but the editors of this site are often having problems with copy&paste. At least parts of the copied text's styling are always copied along.
I'm not 100% sure what happened in your case above, but as I can't recreate the alternating line background whatever I try, nor the line numbering, it must be coming from outside.
To eliminate any potential misclick on creating of the block, do like I always do and simply write out the code block BBCode yourself like so:

[code]
...
[/code]

And the paste inserting can be done without the formatting as well on most OS I know.

Link to comment
Share on other sites

Thanks I will look into activators I used a trigger box because its invisible. I believe I have misinterpreted what I read at Cast - The Elder Scrolls Construction Set Wiki

 

 

  • Cast must be called from a reference. Items in inventories aren't references. Therefore cast won't run if called from a scripted object in an inventory. See talk page for details and workarounds.

The discussion page also led me to believe the script that uses the cast feature cant be part of an item in my inventory. I read somewhere that to get it to work the way I need to is to make an invisible object that still has the ability to collide with in order to use cast function but was not able to find anything on how to make an item or custom npc that would be invisible ( unless its as easy as choosing no nif file which I will test after this post.)

 

with regards to the using the <> to add a script. I type 1 for what line to start on and selected the PHP/Auto/Generic Detect for code selection and I did use copy paste feature. I will try again and leave the 1 out using same code type.

scn OvadBootsScript
Ref Trigger

Begin OnEquip Player

		set trigger to OvadBootsTriggerRef

End

Begin GameMode
	
		If player.issneaking == 1 && player.getequippedobject 5 == OvadBoots
		trigger.moveto player
		elseif player.issneaking == 0
		player.dispel OvadBootsSpell
		endif
	
End

this is my code put on the boots I used Begin OnEquip Player to fix an issue I had with CM Mod follower equipping a pair of my boots and causing me to stay vanished after I used them.

Link to comment
Share on other sites

Ok Almost there folks. Pellape was correct about the spell and DrakeTheDragon is correct on not needing a script to be placed on the activator. I still need to tinker with it a bit because my DoOnce to keep the spell from being cast a billion times back to back isn't working

(Probably due to my being tired as having a million and one edits to what would probably be easier for you more experienced modders). So Thanks for getting me headed in the right direction I will finish later ( after much needed sleep).

 

for the curious I am still using a trigger for my Activator heres the script on my boots thus far.

scn OvadBootsScript
Ref Trigger
ref Home
short DoOnce

Begin OnEquip Player

		set trigger to OvadBootsTriggerRef
		set Home to OvadTriggerHomeRef
End

Begin GameMode
	
	If player.issneaking == 1 && player.getequippedobject 5 == OvadBoots
		If DoOnce == 0
		trigger.moveto player 10,10,10
		trigger.cast OvadBootsSpell player
		trigger.moveto home 100,100,100
		Set DoOnce to 1
		ElseIf DoOnce == 1
		Endif
	Endif
		
	if player.issneaking == 0
		player.dispel OvadBootsSpell
		set DoOnce to 0
		
	Endif
End

Link to comment
Share on other sites

  • Recently Browsing   0 members

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