Jump to content

Scripting Help Needed for my Arena.


AirtightSpring3

Recommended Posts

I am currently making a mod called Riften Depths which adds a city under Riften. One of the features will be an arena but there are a few scripts I need help with. I know how to make it so NPCs spawn when a button is pressed or a chain is pulled, and I can do that if what I seek is not possible. There are two main things I want my arena to do and I need help figuring out how to do.

 

1. There is a Battle Master in the Arena and I want an enemy to be spawned when the Dialogue is over. For example, if the player asked, I want to fight a Bandit (one of the options.) A bandit would then be spawned on one of my x markers and the player would be teleported to the other so the fight would begin. If at all possible I would like this to be a random looking leveled bandit, and I would like the player to get 200 coins upon the defeat of the Bandit. Any ideas on how to make this happen?

 

2. The second thing I want to happen is to add the ability to bet on matches. Meaning that the player will tell the Battle Master they want to bet on NPC 1 or NPC 2, the two will spawn, fight and if the player was right about the victor the player will get 200 gold. Is there any way to make this happen?

 

Thanks for any help you can give me, it is much appreciated.

 

- AirtightSpring3

Link to comment
Share on other sites

1 - make an actor variable and make it equal to a placeactoratme function. that would look something like this:

Actor myActorRef = myXMarker.placeActorAtMe(<an appropriate level bandit actor base>)

here's a link to the CK on that function: http://www.creationkit.com/PlaceActorAtMe_-_ObjectReference

then make him attack the player using startCombat().

To give the PC 200 gold when the bandit is dead have the script loop a statement to see if the bandit is dead and to use utility.wait(1) so that the script isn't just running like crazy in the background and taking up memory. When he is dead exit the loop and give the player 200 gold using the additem function on the player.

 

2 - spawn and store the combatants using the placeActorAtMe() function and then startcombat() between them.

use a similar loop statement as above to watch for their deaths.

 

Does that answer your question? Is that a clear answer?

Link to comment
Share on other sites

you can use a while statement to create a loop. A loop will execute the same lines over and over again until a condition, that you set, is met. You can make that condition that the enemy you spawned is dead, and follow that while statement with a line of code that gives the player 200 gold, so that once the condition is met, the loop ends and the player will get 200 gold.

Here is a link to while statements in case you are not familiar with them: http://www.creationkit.com/Statement_Reference#While_Statement

Edited by Guest
Link to comment
Share on other sites

It wouldn't because an if statement will only check once.

But here is brief look at how loops work:

 

A loop in papyrus looks something like this:

while (count < 10)
debug.notification("count is now: " + count)
count += 1
endWhile

The top line ("while") is the beginning of the loop, in parenthesis is a condition.

When the computer reaches this line it will check the condition and if it is found to be true it will execute all the lines, in order, between the "while" statement and the "endWhile" statement. In this way it is similar to an "if" statement.

However there is one difference...

When the computer reaches the "endWhile" statement, instead of continuing on, like with an "endIf" statement, the computer will go back to the "while" statement and check the condition. If the condition is false then the computer goes back to the "endwhile" statement and continues on with the rest of the script. But if the condition returns true, then the computer will once again start executing each of the statement between the "while" and the "endWhile", in order. Once it reaches the "endWhile" it will once again check to see if the condition is true or not, and if it is false it will exit the loop and start working on the script that comes after the "endWhile", if it is true it will once again loop.

And it will go on and on like this until the condition returns false.

 

The code above displays the value of count and adds one to it multiple time, as long as count is less than 10. If count is 0 at the start, then the debug.notification() line will display 0,1,2,3,4,5,6,7,8,9, but it will not display 10, because 10 is not < 10. At the point that count equals 10 it would exit the loop and continue to any scripts below the endWhile.

 

If your example, the script would look something like this:

;some script about spawning the enemy
while(myBadGuyVariable.isDead() == false)
utility.wait(1.0)
endWhile
Game.getPlayer().addItem(myGoldRefVariable,200)

The "myGoldRefVariable" there is used because I can't remember how to reference the gold item off the top of my head.

Link to comment
Share on other sites

Okay, so when I compile this script...

 

;StartUp

DepthsArenaMarker01.PlaceActorAtMe(DepthsArenaFighter01).StartCombat(Game.GetPlayer())

Game.GetPlayer().MoveTo(DepthsArenaMarker04)

while(DepthsArenaFighter01.GetDeadCount() == false)
utility.wait(1.0)
endWhile
Game.GetPlayer().MoveTo(DeptshArenaMarker05)
Game.GetPlayer().addItem(GoldReward,200)

 

There are no errors.

 

But when I run it in game, after I fight the Bandit once, I can never fight him again without being given 200 gold before the fight. I had to use an ActorBase property instead of an Actor to get the first line to work meaning I had to use a GetDeadCount function instead of a IsDead function to get the script to compile correctly. Is there any way here to reset his death as if it never happened, after the player kills him, so that the player may fight him again?

Link to comment
Share on other sites

the problem is that the function getDeadCount() gives you an integer and you are comparing that with "false" (a boolean). The compiler, behind the scenes is trying to turn the integer into a boolean (it has rules to determine whether an int becomes "true" or "false") this isn't ideal because for one, the boolean it gives you has some strange rules that might not be what you wanted. The other problem is that the function getDeadCount() will check all actors using that actorBase, which might also include actors in other rooms in the game. I would suggest using an actor variable. that would look something like this:

;StartUp
Actor myBaddie ; declare this line with all your other variables near the top.
myBaddie = DepthsArenaMarker01.PlaceActorAtMe(DepthsArenaFighter01)
myBaddie.StartCombat(Game.GetPlayer())

Game.GetPlayer().MoveTo(DepthsArenaMarker04)

while(myBaddie.isDead() == false)
utility.wait(1.0)
endWhile
Game.GetPlayer().MoveTo(DeptshArenaMarker05)
Game.GetPlayer().addItem(GoldReward,200)

By storing the actor you can reference it later. You can also use the function isDead() which is a function from the actor class. It gives you the result of "true" if the actor you are using is dead.

Here's a link to that function: http://www.creationkit.com/IsDead_-_Actor

 

To clean up that actor's dead corpse place this code after the "Game.GetPlayer().addItem(GoldReward,200)" line:

myBaddie.disable(true)
utility.waitGameTime(1.5)
myBaddie.delete()

that will disable the actor, fading them out of view, and then delete it from memory since you don't need him anymore.

Edited by Guest
Link to comment
Share on other sites

  • Recently Browsing   0 members

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