Jump to content

hi im new!


anitdragon13

Recommended Posts

Am new, so if this is the wrong spot to post this in please redirect me. i been looking around, and i don't see any programming stuff? only retexturing, sounds, and models mods... anyways, i wanted to make mods by programming. not papyrus btw, thats not programming its scripting. i tried googling multiple times. can someone direct me? i prefer C#, but C++, Vb, phyton, and C could do. thank you...
Link to comment
Share on other sites

Maybe you're looking for Script Dragon? Without further information, it's hard to recommend any resources to you.

 

BW Papyrus is compiled, so it has more in common with a true programming language than what came before (TESScript). The most similar real life language would probably be Java, so you could start there.

 

Just some random custom code I dug up from somewhere:

 

Scriptname BankAccount extends Account
{Bank Account entity accessible at a bank teller.}

import math

; Interest rate on this account. Accrues daily, so this is a daily rate.
; Interest rate can correspond to any number of securities on the account. (includes deposits as well as loans).
float[] property InterestRate Auto

function initialize()
; Initialize holding list
; TestObject o = TestObject.initialize()

; Initialize ledger
holdingIndex = new int[20]
quantity = new Float[20]
credit = new Bool[20]
value = new Float[20]
price = new Float[20]
InterestRate = new Float[20] ;In daily rate. e.x. a daily rate of 5% = input 0.05.
initialized = true

EndFunction

;Attempts to add(+) or remove(-) "amount" from "accountType" for "owner". If account is a credit account, deduct money from player if adding, or add money to player if removing. Vice versa for debit.
;Handles all errors by returning false if unsuccessful, true if successful.
;Can specify fee also for service in pct (default 0%)
;Refactored from BankAccountTransaction (that method will be deprecated)
bool function adjustAccount(string accountType, float amount, ObjectReference owner, MiscObject Gold001, float feePct = 0.0)
Debug.Trace("BankAccount: " + self + " " + accountType + " " + amount + " " + owner)
bool credit = getHoldingCreditDebitS(accountType)
if (credit) ;e.g. savings account
	Debug.Trace("Credit account accessed")
	int ownerGold = owner.GetItemCount(Gold001)
	float holdingValue = getHoldingValueS(accountType)
	float holdingQuantity = getHoldingQuantityS(accountType)
	float priceF = getHoldingPriceS(accountType)
	; NOTE: fee is applied to account value, not gold received/deposit.
	float amountAfterFee = 0.0
	if (priceF == 0) ; bad price
		return false
	elseif (ownerGold < amount && amount > 0) ;Actor does not have enough gold
		return False
	elseif (holdingValue < (-amount) && amount < 0) ;Account does not have enough value
		return False
	elseif (amount > 0)
		amountAfterFee = amount * (100.0 - feePct) / 100.0
		int amountI = amount as int
		owner.removeItem(Gold001,amountI) ;MUST be positive
		updateHoldingQtyS(accountType,amountAfterFee/priceF)
		Debug.Trace("Adding " + amountAfterFee/priceF + " of " + accountType + " and adding " + amount*-1.0 + " of gold.")
		return true
	elseif (amount < 0)
		amountAfterFee = amount * (100.0 + feePct) / 100.0
		int amountI = amount as int
		amountI = -amountI
		owner.addItem(Gold001,amountI) ;MUST be positive
		updateHoldingQtyS(accountType,amountAfterFee/priceF)
		Debug.Trace("Adding " + amountAfterFee/priceF + " of " + accountType + " and adding " + amount + " of gold.")
		return true
	Else
		return False
	EndIf
else ;debit
	int ownerGold = owner.GetItemCount(Gold001)
	float holdingValue = getHoldingValueS(accountType)
	float holdingQuantity = getHoldingQuantityS(accountType)
	float priceF = getHoldingPriceS(accountType)
	; NOTE: fee is applied to account value, not gold received/deposit.
	float amountAfterFee = 0.0
	if (priceF == 0) ; bad price
		return false
	elseif (ownerGold < (-amount) && amount < 0) ;Actor does not have enough gold
		return False
	elseif (holdingValue < amount && amount > 0) ;Account does not have enough value
		return False
	elseif (amount > 0)
		amountAfterFee = amount * (100.0 + feePct) / 100.0
		int amountI = amount as int
		owner.addItem(Gold001,amountI) ;MUST be positive
		updateHoldingQtyS(accountType,amount/priceF)
		Debug.Trace("Adding " + amountAfterFee/priceF + " of " + accountType + " and adding " + amount + " of gold.")
		return true
	elseif (amount < 0)
		amountAfterFee = amount * (100.0 - feePct) / 100.0
		int amountI = amount as int
		amountI = -amountI
		owner.removeItem(Gold001,amountI) ;MUST be positive
		updateHoldingQtyS(accountType,amount/priceF)
		Debug.Trace("Adding " + amountAfterFee/priceF*-1.0 + " of " + accountType + " and adding " + amount*-1.0 + " of gold.")
		return true
	Else
		return False
	EndIf
EndIf	
EndFunction

; Get interest rate for one holding (24 hour rate)
float function getInterestRate(int holdingIndexN)
int idx = containsHolding(holdingIndexN)
if (idx > -1)
	return InterestRate[idx]
Else
	Debug.Trace("Holding index not found. Interest rate was not returned.")
	return 0.0
EndIf
EndFunction

float function getInterestRateS(string holdingString)
return getInterestRate(HoldingList.StringToIndex(holdingString))
EndFunction

; Set interest rate for one holding (24 hour rate)
function setInterestRate(int holdingIndexN, float rate)
int idx = containsHolding(holdingIndexN)
if (idx > -1)
	InterestRate[idx] = rate
Else
	Debug.Trace("Holding index not found. Interest rate was not updated.")
EndIf
EndFunction

function setInterestRateS(string holdingString, float rate)
setInterestRate(HoldingList.StringToIndex(holdingString),rate)
EndFunction

; Returns (NOT sets) value of this security applying InterestRate for days.
float function calculateValueInterest(int holdingIndexN, float days)
int idx = containsHolding(holdingIndexN)
if (idx > -1)
	if (days == 0)
		return value[idx]
	Elseif (days < 0)
		return 0 ;invalid
		Debug.Trace("Invalid number of days.")
	Else
		return calculateInterestInternal(idx,days)
	EndIf
Else
	Debug.Trace("Holding index not found. Not calculating interest.")
EndIf

EndFunction

float function calculateInterestInternal(int idx,float days)
float calc = pow(InterestRate[idx]+1,days)
calc = calc*value[idx]
return calc
EndFunction

float function calculateValueInterestS(string holdingString, float days)
return calculateValueInterest(HoldingList.StringToIndex(holdingString),days)
EndFunction

; Does interest rate update by increasing quantity.
function updateInterestQty(float days)
if (days == 0)
	; do nothing
Elseif (days < 0)
	; invalid
	Debug.Trace("Invalid number of days.")
Else
	int currentElement = 0
	while (currentElement < numHoldings)
		float updateAmt = calculateInterestInternal(currentElement,days)
		float qty = (updateAmt/price[currentElement])
		Debug.Trace("BankAccount: Running rate update for holding " + currentElement + " : old value " + value[currentElement] + " new value " + updateAmt + " new qty " + qty)
		quantity[currentElement] = qty
		value[currentElement] = updateAmt
		currentElement += 1		
	endwhile
EndIf
EndFunction

Edited by jimhsu
Link to comment
Share on other sites

Script dragon on the other hand is heavily influenced by C++ (in fact, it's basically a wrapper around C++):

 

/*
		HORSE SPAWNER SCRIPT PLUGIN EXAMPLE

THIS FILE IS A PART OF THE SKYRIM DRAGON SCRIPT PROJECT	
			(C) Alexander Blade 2011
		http://Alexander.SannyBuilder.com
*/

#include "common\skyscript.h"
#include "common\obscript.h"
#include "common\types.h"
#include "common\enums.h"
#include "common\plugin.h"
#include <math.h>

#define CONFIG_FILE "horsespawner.ini"
#define SCR_NAME "Horse spawner"

void GetRelXyFromRef(TESObjectREFR *ref, float dist, float addangle, float *x, float *y)
{
float rzrot = ObjectReference::GetAngleZ(ref);
rzrot = (float)(rzrot * 3.14 / 180) + addangle;
if (x) *x = dist*sin(rzrot);
if (y) *y = dist*cos(rzrot);
}

void main()
{
BYTE key = IniReadInt(CONFIG_FILE, "main", "key", 0);
PrintNote("[%s] started, press '%s' to use", SCR_NAME, GetKeyName(key).c_str());
while (TRUE)
{
	if (GetKeyPressed(key))
	{
		PrintNote("[%s] : spawning horse", SCR_NAME);
		CActor *player = Game::GetPlayer(); 
		CActor *horse = Game::GetPlayersLastRiddenHorse();
		if (!horse)
		{
			 /* if object to cast has no multiply parent classes then dyn_cast result will be the same as input src object
			 it's necessary to do such casts only if you want to verify object class */
			horse = (CActor *)dyn_cast(Game::GetFormById(ID_Character::SolitudePlayersHorseRef), "TESForm", "CActor");
			if (!horse)
			{
				PrintNote("you shouldn't see this : invalid horse id specified, terminating script");
				return;
			}
			TESNPC *player_npc = (TESNPC *)dyn_cast(Game::GetFormById(ID_TESNPC::Player), "TESForm", "TESNPC");
			if (!player_npc)
			{
				PrintNote("you shouldn't see this : invalid player_npc id specified, terminating script");
				return;
			}
			// for ex. SetActorOwner has 1st param as TESObjectREFR* , CActor is alerady a REFR class by itself
			// u must not make dyn_cast 
			ObjectReference::SetActorOwner((TESObjectREFR *)horse, player_npc);
			TESObjectCELL * pc = ObjectReference::GetParentCell((TESObjectREFR *)horse);
			PrintNote("cell 0x%08x", pc);
			//ObjectReference::SetFactionOwner((TESObjectREFR *)horse, (TESFaction *)Game::GetFormById(ID_TESFaction::PlayerFaction));
			//Cell::SetFactionOwner((TESObjectCELL *)horse, (TESFaction *)Game::GetFormById(ID_TESFaction::PlayerFaction));
		}
		if (Actor::IsDead(horse)) 
		{
			PrintNote("[%s] : your horse may look like dead for some time", SCR_NAME);
			Actor::Resurrect(horse);
		}
		Actor::ResetHealthAndLimbs(horse);
		float xdif, ydif;
		GetRelXyFromRef((TESObjectREFR *)player, 300, 0, &xdif, &ydif);
		ObjectReference::MoveTo((TESObjectREFR *)horse, (TESObjectREFR *)player, xdif, ydif, 0, TRUE);
		PrintNote("[%s] : horse spawned", SCR_NAME);
		Wait(500);
	}
	Wait(0); // In order to switch between script threads Wait() must be called anyway
}
}

 

Your choice on which one to use. Both have their advantages and disadvantages.

Link to comment
Share on other sites

 

Like what? Sorry, I'm a very curious person, and maybe it is possible with the Creation Kit.

lol its ok. lets say, you want to make a RTS game type base on skyrim models and game play? or you want to make a battle grounds to vs your friends? or even a Dota game type? all of them seem impossible.. but, i like challenges and it would seem very cool to see stuff like that on the site :)

 

Maybe you're looking for Script Dragon? Without further information, it's hard to recommend any resources to you.

 

BW Papyrus is compiled, so it has more in common with a true programming language than what came before (TESScript). The most similar real life language would probably be Java, so you could start there.

 

Script dragon on the other hand is heavily influenced by C++ (in fact, it's basically a wrapper around C++):

 

Your choice on which one to use. Both have their advantages and disadvantages.

thank you very much, i'll look into that

btw @jimhsu the first code you put up is ether Assembly Languages or ALGOL 60 and the 2nd is more than likely C++ or C (witch are the same thing)

Edited by anitdragon13
Link to comment
Share on other sites

lol its ok. lets say, you want to make a RTS game type base on skyrim models and game play? or you want to make a battle grounds to vs your friends? or even a Dota game type? all of them seem impossible.. but, i like challenges and it would seem very cool to see stuff like that on the site :)

 

I dont really think it's possible to program skyrim. You'd have to hack the engine first, which i think is illegal.

Also... you should take a look at the ck first, it's a powerfull tool.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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