{
FIREAMMO[pistolbullet]//Projectilefiredbypawn
FIREEFFECT[Electric]//muzzleflasheffect
WEAPONMODEL[Laser]//Weaponheldbypawn
FIRERATE[0.1]//Weaponfiringrate
GROUP[player]//PawnGroup-mustbetargettedbyenemies
PLAYERSPEED[96]//WalkSpeed
HEALTHATTRIB[Health]//healthattributegiventopawn
HEALTHAMOUNT[500]//amountofhealthgiventopawn
DAMAGEATTRIB[Health]//Atributedamagedbypawn
BOX[24]//Boxwidth
IDLEANIM[Idle]//IdleAnimationSpeed
WALKANIM[Walk]//Walkanim
BACKANIM[WalkBack]//Walkbackanim
STRAFELEFT[StrafeLeft]//Strafeleftanim
STRAFERIGHT[StrafeRight]//Straferightanim
INTERANIM//Pawninteractanim
DEATHANIM[Die]//DeathAnim
ROOTBONE[Bip01]//Pawnrootbone
WEAPONHAND[Bip01LHand]//Pawnweaponbone
K_INTER[73]//INTERACTKEY-RIGHTMOUSE
K_FIRE[72]//FIREKEY-LEFTMOUSE
K_FOR[15]//FORWARD-W
K_BAK[27]//BACK-S
K_LEFT[26]//STRAFELEFT-A
K_RIGHT[28]//STRAFERIGHT-D
K_RUN[36]//RUN-LEFTSHIFTKEY
ANIM[string]//DoNotEdit
ANC[0]//DoNotEdit
LASTANC[0]//DoNotEdit
DIR[0]//DoNotEdit
AT[0.5]//DoNotEdit
INTER[string]//DoNotEdit
TM[0]//DoNotEdit
SPEED[0]//DoNotEdit
TARGET[FALSE]//thecurrenttarget
MELEE_DAMAGE[10]//basedamageyoudowithmeleeweapon
MELEE_DIST[128]//maximumdistanceneededformeleeattack
MELEE_ANIM[Slash1]//meleeattackanimation
MELEE_RATE[2.0]//timebetweenmeleeattacks
MELEE_DAMAGEATTRIB[Health]//attributethatisdamagedbymeleeattack
LEVELUP_BACKGROUND_X[128]//thehalfof(screensizeX-imagesizeX)
LEVELUP_BACKGROUND_Y[128]//thehalfof(screensizeY-imagesizeY)
LEVELUP_PLUSSES_X[192]//LEVELUP_BACKGROUND+64
LEVELUP_PLUSSES_Y[256]//LEVELUP_BACKGROUND+128
LEVELUP_HEADLINE[Level-Up]
LEVELUP_HEADLINE_X[48]
LEVELUP_HEADLINE_Y[48]
LEVELUP_TEXTS_X[160]
LEVELUP_TEXTS_Y[160]
MOUSEX[0]
MOSUEY[0]
MOUSE_TRANSX[0]
MOUSE_TRANSY[0]
MOUSE_LOCATION[Nowhere]
STATS_RAISEPERLEVEL[5]//numberofstatpointsthatcanberaisedeachlevel
STATS_RAISED[0]//numberofstatpointsraisedalreadyatthislevel.//Setbackto0wheneveralevelwasreached
Spawn[()
{
Console(true);
BoxWidth(BOX);
SetGroup(GROUP);
AddAttribute(HEALTHATTRIB,0,GetAttribute("Stamina","Player")*5);
SetAttribute(HEALTHATTRIB,GetAttribute("Stamina","Player")*5);
//SetWeapon(WEAPONMODEL);
LowLevel("SetupL");
}]
SetupL[()
{
AttachCamera();
self.yaw_speed=256;
AnimateHold(IDLEANIM);
ANIM=StringCopy(IDLEANIM);
ANC=0;
LASTANC=0;
TM=self.time;
self.think="RunPlayer";
}]
RunPlayer[()
{
//debug(self.key_pressed);
PlayerRender(false);
self.ideal_yaw=self.player_yaw;
ChangeYaw();
DIR=0;//Defaultstraight
SPEED=0;//Default-nomotion
AT=0.1;//Default
ANC=0;//Default
AnimationSpeed(1);//Default
//handlehealthstatus
if(GetAttribute(HEALTHATTRIB)<1)
{
HighLevel("Die");
return0;
}
//handlecontrols
if(IsKeyDown(K_INTER))
{
//strike/interact
AnimateBlend(INTERANIM,0.25);
self.think="Interact";
return0;
}
if(IsKeyDown(K_FOR))
{
//forward
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_BAK))
{
//back
ANIM=StringCopy(BACKANIM);
ANC=3;
DIR=ConvertDegrees(180);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_LEFT))
{
//strafeleft
ANIM=StringCopy(STRAFELEFT);
//makestrafetransitionsmoother
AT=0.5;
ANC=4;
DIR=ConvertDegrees(90);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_RIGHT))
{
//straferight
ANIM=StringCopy(STRAFERIGHT);
//makestrafetransitionsmoother
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_FIRE))
{
//fire/attack
if(ANC<1)
{
//onlygotoshootanimifatidle
ANIM=StringCopy(MELEE_ANIM));
ANC=1;
}
//Checkfirerate
if(self.time>TM+MELEE_RATE)
{
TM=self.time;
TARGET=TraceToActor("BIP01FOOTSTEPS",0,1,MELEE_DIST);
If(TARGET="FALSE")
{
//donothing
;
}
else
{
DamageEntity(MELEE_DAMAGE,MELEE_DAMAGEATTRIB*GetAttribute("Strength","Player")/20,TARGET);
}
TM=self.time;
}
}
if(ANC<1)
{
//nobutton
ANIM=StringCopy(IDLEANIM);
AT=0.5;
}
if(IsKeyDown(K_RUN))
{
//leftshiftkey-togglerun
AnimationSpeed(1.5);
SPEED=SPEED+(SPEED/2);
}
//handleanimations
if(Integer(LASTANC)!=Integer(ANC))
{
AnimateBlend(ANIM,AT);
}
LASTANC=Integer(ANC);
if(self.animate_at_end)
{
AnimateHold(ANIM);
}
//handlemotions
walkmove(self.current_yaw+DIR,SPEED*GetAttribute("Speed","Player")/20);
if(GetAttribute("exp","Player")>(GetAttribute("nextexp","Player")-1))
{
ModifyAttribute("exp",GetAttribute("nextexp","Player")*(-1),"Player");
ModifyAttribute("nextexp",1000,"Player");
ModifyAttribute("level",1,"Player");
self.think="LevelUp";
}
}]
Interact[()
{
if(self.animate_at_end)
{
INTER=TraceToActor(ROOTBONE,0,0,32);
if(INTER!="FALSE")
{
SetEventState(INTER#"Trigger",true);
}
self.think="RunPlayer";
return0;
}
}]
Die[()
{
AnimateStop(DEATHANIM,0,"");
}]
DrawLevelUpScreen[()
{
DrawFlipBookImage("Levelup",0,LEVELUP_BACKGROUND_X,
LEVELUP_BACKGROUND_Y,255,255,255,255,1.0);//0=background
DrawFlipBookImage("Levelup",1,LEVELUP_PLUSSES_X,
LEVELUP_PLUSSES_Y,255,255,255,255,1.0);//1=Plus
DrawFlipBookImage("Levelup",1,LEVELUP_PLUSSES_X,
LEVELUP_PLUSSES_Y+64,255,255,255,255,1.0);//1=Plus
DrawFlipBookImage("Levelup",1,LEVELUP_PLUSSES_X,
LEVELUP_PLUSSES_Y+128,255,255,255,255,1.0);//1=Plus
DrawFlipBookImage("Levelup",1,LEVELUP_PLUSSES_X,
LEVELUP_PLUSSES_Y+192,255,255,255,255,1.0);//1=Plus
//drawheadlineandnameofthestats
DrawText(LEVELUP_HEADLINE,LEVELUP_HEADLINE_X,
LEVELUP_HEADLINE_Y,255,10,255,255,255);
DrawText("Strength",LEVELUP_TEXTS_X,LEVELUP_TEXTS_Y,255,10,
255,255,255);
DrawText("Stamina",LEVELUP_TEXTS_X,LEVELUP_TEXTS_Y+64,255,
10,255,255,255);
DrawText("Speed",LEVELUP_TEXTS_X,LEVELUP_TEXTS_Y+128,255,
10,255,255,255);
//drawthestat-values
DrawText(GetAttribute("Strength","Player"),LEVELUP_TEXTS_X+256,
LEVELUP_TEXTS_Y,255,10,255,255,255);
DrawText(GetAttribute("Stamina","Player"),LEVELUP_TEXTS_X+256,
LEVELUP_TEXTS_Y+64,255,10,255,255,255);
DrawText(GetAttribute("Speed","Player"),LEVELUP_TEXTS_X+256,
LEVELUP_TEXTS_Y+128,255,10,255,255,255);
}]
TranslateMouseCoordsLevelUp[()
{
MOUSEX=GetMousePosX();
MOUSEY=GetMousePosY();
MOUSE_TRANSX=StringCopy(MOUSEX)-StringCopy(LEVELUP_BACKGROUND_X);
MOUSE_TRANSY=StringCopy(MOUSEY)-StringCopy(LEVELUP_BACKGROUND_Y);
MOUSE_LOCATION="Nowhere";
if(MOUSE_TRANSX<0)
{
return0;
}
if(MOUSE_TRANSY<0)
{
return0;
}
if(MOUSE_TRANSX>768)
{
return0;
}
if(MOUSE_TRANSY>512)
{
return0;
}
if(MOUSE_TRANSX>63andMOUSE_TRANSX<129)
{
if(MOUSE_TRANSY>127andMOUSE_TRANSY<385)
{
if(MOUSE_TRANSY<193)
{
MOUSE_LOCATION="LevelUp_Strength";
return1;
}
if(MOUSE_TRANSY>191andMOUSE_TRANSY<257)
{
MOUSE_LOCATION="LevelUp_Stamina";
return1;
}
if(MOUSE_TRANSY>255andMOUSE_TRANSY<321)
{
MOUSE_LOCATION="LevelUp_Speed";
return1;
}
}
}
MOUSE_LOCATION="LevelUp_Background";
return1;
}]
LevelUp[()
{
if(STATS_RAISED=StringCopy(STATS_RAISEPERLEVEL))
{
STATS_RAISED=0;
self.think="RunPlayer";
return1;
}
DrawLevelUpScreen();
if(self.lbutton_pressed)
{
if(TranslateMouseCoordsLevelUp())
{
switch(MOUSE_LOCATION)
{
case"LevelUp_Strength"
{
ModifyAttribute("Strength",1,"Player");
STATS_RAISED=StringCopy(STATS_RAISED)+1;
}
case"LevelUp_Stamina"
{
ModifyAttribute("Stamina",1,"Player");
STATS_RAISED=StringCopy(STATS_RAISED)+1;
//updatethehealthattribute
SetAttributeValueLimitsHEALTHATTRIB,0,
GetAttribute("Stamina","Player")*5);
SetAttribute(HEALTHATTRIB,GetAttribute("Stamina","Player")*5);
}
case"LevelUp_Speed"
{
ModifyAttribute("Speed",1,"Player");
STATS_RAISED=StringCopy(STATS_RAISED)+1;
}
}
}
}
}]
}
Hiya good people of the reality factory boards. I'm new here, so please be gentle with me if I ask dumb questions - but no kid gloves. Above is a script (slightly editted, but more or less exactly input as described in the rpg tutorial) which for one or other reason won't run!! I have my pawn setup in the editor - spawn order is 'Spawn' - made sure caps and the like were correct - and matched the pawntype to the [] named actor I wanted to use. When I don't put a command in the spawn order, the pawn appears in the game where it should, but with the script activated...it is invisible and not present as the player character. I'd be very grateful if enyone could be so kind as to look at the script as is and let me know where I'm going wrong - or perhaps another idea of what I effed up. Cheers and thanks in advance...
Ever